Skip to content

Commit

Permalink
Update for Swift 4.0 (#228)
Browse files Browse the repository at this point in the history
Now uses Swift 4.0 and requires Xcode 9.0.
  • Loading branch information
paulw11 authored and p2 committed Sep 25, 2017
1 parent 409d084 commit e630ac7
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c # well "swift" actually
osx_image: xcode8
osx_image: xcode9
xcode_project: OAuth2.xcodeproj
xcode_scheme: OAuth2macOS
xcode_sdk: macosx
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Contributors to the codebase, in reverse chronological order:
- Tomohiro Kumagai, @ez-net
- Tim Sneed, @trsneed
- Vojto Rinik, @vojto
- Paul Wilkinson, @paulw11
28 changes: 20 additions & 8 deletions OAuth2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Pascal Pfiffner";
TargetAttributes = {
659854451C5B3BEA00237D39 = {
Expand All @@ -580,7 +580,7 @@
};
EEE209A119427DFE00736F1A = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
TestTargetID = EEE209461942772800736F1A;
};
};
Expand Down Expand Up @@ -872,14 +872,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -909,7 +915,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -924,14 +930,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -952,7 +964,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
METAL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -978,7 +990,7 @@
PRODUCT_NAME = OAuth2;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1000,7 +1012,7 @@
PRODUCT_NAME = OAuth2;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1022,7 +1034,7 @@
PRODUCT_NAME = OAuth2;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1046,7 +1058,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
4 changes: 3 additions & 1 deletion OAuth2.xcodeproj/xcshareddata/xcschemes/OAuth2iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 3 additions & 1 deletion OAuth2.xcodeproj/xcshareddata/xcschemes/OAuth2macOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -69,6 +70,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 3 additions & 1 deletion OAuth2.xcodeproj/xcshareddata/xcschemes/OAuth2tvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Base/OAuth2Base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ open class OAuth2ContextStore {
open var state: String {
if _state.isEmpty {
_state = UUID().uuidString
_state = _state[_state.startIndex..<_state.index(_state.startIndex, offsetBy: 8)] // only use the first 8 chars, should be enough
_state = String(_state[_state.startIndex..<_state.index(_state.startIndex, offsetBy: 8)]) // only use the first 8 chars, should be enough
}
return _state
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Base/OAuth2Requestable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ open class OAuth2Requestable {
/**
Helper function to ensure that the callback is executed on the main thread.
*/
public func callOnMainThread(_ callback: ((Void) -> Void)) {
public func callOnMainThread(_ callback: (() -> Void)) {
if Thread.isMainThread {
callback()
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/iOS/OAuth2WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ open class OAuth2WebViewController: UIViewController, WKNavigationDelegate {
let _ = webView?.load(URLRequest(url: url))
}

func goBack(_ sender: AnyObject?) {
@objc func goBack(_ sender: AnyObject?) {
let _ = webView?.goBack()
}

func cancel(_ sender: AnyObject?) {
@objc func cancel(_ sender: AnyObject?) {
dismiss(asCancel: true, animated: (nil != sender) ? true : false)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/macOS/OAuth2Authorizer+macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
- throws: UnableToOpenAuthorizeURL on failure
*/
public func openAuthorizeURLInBrowser(_ url: URL) throws {
if !NSWorkspace.shared().open(url) {
if !NSWorkspace.shared.open(url) {
throw OAuth2Error.unableToOpenAuthorizeURL
}
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/macOS/OAuth2WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS

/** Designated initializer. */
public init() {
super.init(nibName: nil, bundle: nil)!
super.init(nibName: nil, bundle: nil)
}

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

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

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

progressIndicator = NSProgressIndicator(frame: NSZeroRect)
progressIndicator.style = .spinningStyle
progressIndicator.style = .spinning
progressIndicator.isDisplayedWhenStopped = false
progressIndicator.sizeToFit()
progressIndicator.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -216,7 +216,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS
/**
Tells the web view to stop loading the current page, then calls the `onWillCancel` block if it has a value.
*/
func cancel(_ sender: AnyObject?) {
@objc func cancel(_ sender: AnyObject?) {
webView.stopLoading()
onWillCancel?()
}
Expand Down Expand Up @@ -281,7 +281,7 @@ public class OAuth2WebViewController: NSViewController, WKNavigationDelegate, NS

// MARK: - Window Delegate

public func windowShouldClose(_ sender: Any) -> Bool {
public func windowShouldClose(_ sender: NSWindow) -> Bool {
onWillCancel?()
return false
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftKeychain

0 comments on commit e630ac7

Please sign in to comment.