Skip to content

Commit e630ac7

Browse files
paulw11p2
authored andcommitted
Update for Swift 4.0 (#228)
Now uses Swift 4.0 and requires Xcode 9.0.
1 parent 409d084 commit e630ac7

13 files changed

+43
-24
lines changed

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c # well "swift" actually
2-
osx_image: xcode8
2+
osx_image: xcode9
33
xcode_project: OAuth2.xcodeproj
44
xcode_scheme: OAuth2macOS
55
xcode_sdk: macosx

CONTRIBUTORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Contributors to the codebase, in reverse chronological order:
1818
- Tomohiro Kumagai, @ez-net
1919
- Tim Sneed, @trsneed
2020
- Vojto Rinik, @vojto
21+
- Paul Wilkinson, @paulw11

OAuth2.xcodeproj/project.pbxproj

+20-8
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@
565565
attributes = {
566566
LastSwiftMigration = 0700;
567567
LastSwiftUpdateCheck = 0700;
568-
LastUpgradeCheck = 0810;
568+
LastUpgradeCheck = 0900;
569569
ORGANIZATIONNAME = "Pascal Pfiffner";
570570
TargetAttributes = {
571571
659854451C5B3BEA00237D39 = {
@@ -580,7 +580,7 @@
580580
};
581581
EEE209A119427DFE00736F1A = {
582582
CreatedOnToolsVersion = 6.0;
583-
LastSwiftMigration = 0800;
583+
LastSwiftMigration = 0900;
584584
TestTargetID = EEE209461942772800736F1A;
585585
};
586586
};
@@ -872,14 +872,20 @@
872872
CLANG_CXX_LIBRARY = "libc++";
873873
CLANG_ENABLE_MODULES = YES;
874874
CLANG_ENABLE_OBJC_ARC = YES;
875+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
875876
CLANG_WARN_BOOL_CONVERSION = YES;
877+
CLANG_WARN_COMMA = YES;
876878
CLANG_WARN_CONSTANT_CONVERSION = YES;
877879
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
878880
CLANG_WARN_EMPTY_BODY = YES;
879881
CLANG_WARN_ENUM_CONVERSION = YES;
880882
CLANG_WARN_INFINITE_RECURSION = YES;
881883
CLANG_WARN_INT_CONVERSION = YES;
884+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
885+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
882886
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
887+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
888+
CLANG_WARN_STRICT_PROTOTYPES = YES;
883889
CLANG_WARN_SUSPICIOUS_MOVE = YES;
884890
CLANG_WARN_UNREACHABLE_CODE = YES;
885891
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -909,7 +915,7 @@
909915
ONLY_ACTIVE_ARCH = YES;
910916
SDKROOT = iphoneos;
911917
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
912-
SWIFT_VERSION = 3.0;
918+
SWIFT_VERSION = 4.0;
913919
TARGETED_DEVICE_FAMILY = "1,2";
914920
VERSIONING_SYSTEM = "apple-generic";
915921
VERSION_INFO_PREFIX = "";
@@ -924,14 +930,20 @@
924930
CLANG_CXX_LIBRARY = "libc++";
925931
CLANG_ENABLE_MODULES = YES;
926932
CLANG_ENABLE_OBJC_ARC = YES;
933+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
927934
CLANG_WARN_BOOL_CONVERSION = YES;
935+
CLANG_WARN_COMMA = YES;
928936
CLANG_WARN_CONSTANT_CONVERSION = YES;
929937
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
930938
CLANG_WARN_EMPTY_BODY = YES;
931939
CLANG_WARN_ENUM_CONVERSION = YES;
932940
CLANG_WARN_INFINITE_RECURSION = YES;
933941
CLANG_WARN_INT_CONVERSION = YES;
942+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
943+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
934944
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
945+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
946+
CLANG_WARN_STRICT_PROTOTYPES = YES;
935947
CLANG_WARN_SUSPICIOUS_MOVE = YES;
936948
CLANG_WARN_UNREACHABLE_CODE = YES;
937949
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -952,7 +964,7 @@
952964
MACOSX_DEPLOYMENT_TARGET = 10.9;
953965
METAL_ENABLE_DEBUG_INFO = NO;
954966
SDKROOT = iphoneos;
955-
SWIFT_VERSION = 3.0;
967+
SWIFT_VERSION = 4.0;
956968
TARGETED_DEVICE_FAMILY = "1,2";
957969
VALIDATE_PRODUCT = YES;
958970
VERSIONING_SYSTEM = "apple-generic";
@@ -978,7 +990,7 @@
978990
PRODUCT_NAME = OAuth2;
979991
SKIP_INSTALL = YES;
980992
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
981-
SWIFT_VERSION = 3.0;
993+
SWIFT_VERSION = 4.0;
982994
};
983995
name = Debug;
984996
};
@@ -1000,7 +1012,7 @@
10001012
PRODUCT_NAME = OAuth2;
10011013
SKIP_INSTALL = YES;
10021014
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1003-
SWIFT_VERSION = 3.0;
1015+
SWIFT_VERSION = 4.0;
10041016
};
10051017
name = Release;
10061018
};
@@ -1022,7 +1034,7 @@
10221034
PRODUCT_NAME = OAuth2;
10231035
SDKROOT = macosx;
10241036
SKIP_INSTALL = YES;
1025-
SWIFT_VERSION = 3.0;
1037+
SWIFT_VERSION = 4.0;
10261038
};
10271039
name = Debug;
10281040
};
@@ -1046,7 +1058,7 @@
10461058
SDKROOT = macosx;
10471059
SKIP_INSTALL = YES;
10481060
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1049-
SWIFT_VERSION = 3.0;
1061+
SWIFT_VERSION = 4.0;
10501062
};
10511063
name = Release;
10521064
};

OAuth2.xcodeproj/xcshareddata/xcschemes/OAuth2iOS.xcscheme

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

OAuth2.xcodeproj/xcshareddata/xcschemes/OAuth2macOS.xcscheme

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -40,6 +40,7 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
language = ""
4344
shouldUseLaunchSchemeArgsEnv = "YES">
4445
<Testables>
4546
<TestableReference
@@ -69,6 +70,7 @@
6970
buildConfiguration = "Debug"
7071
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7172
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73+
language = ""
7274
launchStyle = "0"
7375
useCustomWorkingDirectory = "NO"
7476
ignoresPersistentStateOnLaunch = "NO"

OAuth2.xcodeproj/xcshareddata/xcschemes/OAuth2tvOS.xcscheme

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

Sources/Base/OAuth2Base.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ open class OAuth2ContextStore {
471471
open var state: String {
472472
if _state.isEmpty {
473473
_state = UUID().uuidString
474-
_state = _state[_state.startIndex..<_state.index(_state.startIndex, offsetBy: 8)] // only use the first 8 chars, should be enough
474+
_state = String(_state[_state.startIndex..<_state.index(_state.startIndex, offsetBy: 8)]) // only use the first 8 chars, should be enough
475475
}
476476
return _state
477477
}

Sources/Base/OAuth2Requestable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ open class OAuth2Requestable {
213213
/**
214214
Helper function to ensure that the callback is executed on the main thread.
215215
*/
216-
public func callOnMainThread(_ callback: ((Void) -> Void)) {
216+
public func callOnMainThread(_ callback: (() -> Void)) {
217217
if Thread.isMainThread {
218218
callback()
219219
}

Sources/iOS/OAuth2WebViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ open class OAuth2WebViewController: UIViewController, WKNavigationDelegate {
167167
let _ = webView?.load(URLRequest(url: url))
168168
}
169169

170-
func goBack(_ sender: AnyObject?) {
170+
@objc func goBack(_ sender: AnyObject?) {
171171
let _ = webView?.goBack()
172172
}
173173

174-
func cancel(_ sender: AnyObject?) {
174+
@objc func cancel(_ sender: AnyObject?) {
175175
dismiss(asCancel: true, animated: (nil != sender) ? true : false)
176176
}
177177

Sources/macOS/OAuth2Authorizer+macOS.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
6060
- throws: UnableToOpenAuthorizeURL on failure
6161
*/
6262
public func openAuthorizeURLInBrowser(_ url: URL) throws {
63-
if !NSWorkspace.shared().open(url) {
63+
if !NSWorkspace.shared.open(url) {
6464
throw OAuth2Error.unableToOpenAuthorizeURL
6565
}
6666
}

Sources/macOS/OAuth2WebViewController.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS
3434

3535
/** Designated initializer. */
3636
public init() {
37-
super.init(nibName: nil, bundle: nil)!
37+
super.init(nibName: nil, bundle: nil)
3838
}
3939

4040
/// Handle to the OAuth2 instance in play, only used for debug logging at this time.
@@ -78,7 +78,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS
7878
public var onIntercept: ((URL) -> Bool)?
7979

8080
/// Called when the web view is about to be dismissed manually.
81-
public var onWillCancel: ((Void) -> Void)?
81+
public var onWillCancel: (() -> Void)?
8282

8383
/// Our web view; implicitly unwrapped so do not attempt to use it unless isViewLoaded() returns true.
8484
var webView: WKWebView!
@@ -89,7 +89,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS
8989
view.translatesAutoresizingMaskIntoConstraints = false
9090

9191
progressIndicator = NSProgressIndicator(frame: NSZeroRect)
92-
progressIndicator.style = .spinningStyle
92+
progressIndicator.style = .spinning
9393
progressIndicator.isDisplayedWhenStopped = false
9494
progressIndicator.sizeToFit()
9595
progressIndicator.translatesAutoresizingMaskIntoConstraints = false
@@ -216,7 +216,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS
216216
/**
217217
Tells the web view to stop loading the current page, then calls the `onWillCancel` block if it has a value.
218218
*/
219-
func cancel(_ sender: AnyObject?) {
219+
@objc func cancel(_ sender: AnyObject?) {
220220
webView.stopLoading()
221221
onWillCancel?()
222222
}
@@ -281,7 +281,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS
281281

282282
// MARK: - Window Delegate
283283

284-
public func windowShouldClose(_ sender: Any) -> Bool {
284+
public func windowShouldClose(_ sender: NSWindow) -> Bool {
285285
onWillCancel?()
286286
return false
287287
}

SwiftKeychain

0 commit comments

Comments
 (0)