Skip to content

Commit

Permalink
Migrate to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
edjiang committed Aug 17, 2017
1 parent a330fe8 commit b9931d0
Show file tree
Hide file tree
Showing 47 changed files with 274 additions and 260 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: objective-c
xcode_project: source/UberRides.xcodeproj # path to your xcodeproj folder
xcode_scheme: UberRides
osx_image: xcode8.3
osx_image: xcode9
before_install:
- brew install carthage
install:
- carthage bootstrap --platform ios
script:
- xcodebuild clean build -sdk iphonesimulator -project source/UberRides.xcodeproj -scheme UberRides -destination "OS=8.4,name=iPhone 4S" CODE_SIGNING_REQUIRED=NO test
- xcodebuild clean build -sdk iphonesimulator -project source/UberRides.xcodeproj -scheme UberRides -destination "OS=9.3,name=iPhone 4S" CODE_SIGNING_REQUIRED=NO test
32 changes: 22 additions & 10 deletions source/UberRides.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -655,21 +655,21 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Uber;
TargetAttributes = {
AC0404741BFACD1D00AC1501 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 0900;
};
AC04047E1BFACD1D00AC1501 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 0900;
TestTargetID = DCDD153A1D99A7F20053BC8F;
};
DCDD153A1D99A7F20053BC8F = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0810;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Keychain = {
Expand Down Expand Up @@ -954,14 +954,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 @@ -1005,14 +1011,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 @@ -1059,7 +1071,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1080,7 +1092,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.uber.sdk.UberRides;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1093,7 +1105,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.uber.sdk.UberRidesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestAppShim.app/TestAppShim";
};
name = Debug;
Expand All @@ -1107,7 +1119,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.uber.sdk.UberRidesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestAppShim.app/TestAppShim";
};
name = Release;
Expand All @@ -1127,7 +1139,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.uber.sdk.UberRides.TestAppShim;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1146,7 +1158,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.uber.sdk.UberRides.TestAppShim;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
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 source/UberRides/AppStoreDeeplink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Foundation

- returns: An initialized AppStoreDeeplink
*/
public init(userAgent: String?) {
@objc public init(userAgent: String?) {
let scheme = "https"
let domain = "m.uber.com"
let path = "/sign-up"
Expand Down
2 changes: 1 addition & 1 deletion source/UberRides/AuthenticationDeeplink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Foundation

- returns: An initialized AuthenticationDeeplink
*/
public init(scopes: [RidesScope]) {
@objc public init(scopes: [RidesScope]) {
let queryItems = AuthenticationURLUtility.buildQueryParameters(scopes)
let scheme = "uberauth"
let domain = "connect"
Expand Down
34 changes: 17 additions & 17 deletions source/UberRides/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ private let callbackURIStringKey = "URIString"
*/
@objc(UBSDKConfiguration) open class Configuration : NSObject {
// MARK : Variables
open static var shared: Configuration = Configuration()
@objc open static var shared: Configuration = Configuration()

/// The .plist file to use, default is Info.plist
open static var plistName = "Info"
@objc open static var plistName = "Info"

/// The bundle that contains the .plist file. Default is the mainBundle()
open static var bundle = Bundle.main
@objc open static var bundle = Bundle.main

open var processPool = WKProcessPool()
@objc open var processPool = WKProcessPool()

/**
Gets the client ID of this app. Defaults to the value stored in your Application's
plist if not set (UberClientID)

- returns: The string to use for the Client ID
*/
open var clientID: String
@objc open var clientID: String

private var callbackURIs = [CallbackURIType: String]()

Expand All @@ -110,7 +110,7 @@ private let callbackURIStringKey = "URIString"

- returns: The app's name
*/
open var appDisplayName: String
@objc open var appDisplayName: String

/**
Gets the Server Token of this app. Defaults to the value stored in your Appication's
Expand All @@ -120,30 +120,30 @@ private let callbackURIStringKey = "URIString"

- returns: The string Representing your app's server token
*/
open var serverToken: String?
@objc open var serverToken: String?

/**
Gets the default keychain access group to save access tokens to. Advanced setting
for sharing access tokens between multiple of your apps. Defaults an empty string

- returns: The default keychain access group to use
*/
open var defaultKeychainAccessGroup: String = ""
@objc open var defaultKeychainAccessGroup: String = ""

/**
Gets the default key to use when saving access tokens to the keychain. Defaults
to using "RidesAccessTokenKey"

- returns: The default access token identifier to use
*/
open var defaultAccessTokenIdentifier: String = "RidesAccessTokenKey"
@objc open var defaultAccessTokenIdentifier: String = "RidesAccessTokenKey"

/**
Returns if sandbox is enabled or not

- returns: true if Sandbox is enabled, false otherwise
*/
open var isSandbox: Bool = false
@objc open var isSandbox: Bool = false

/**
Returns if the fallback to use Authorization Code Grant is enabled. If true,
Expand All @@ -152,7 +152,7 @@ private let callbackURIStringKey = "URIString"

- returns: true if fallback enabled, false otherwise
*/
open var useFallback: Bool = true
@objc open var useFallback: Bool = true

public override init() {
self.clientID = ""
Expand All @@ -174,7 +174,7 @@ private let callbackURIStringKey = "URIString"
}

/// The current version of the SDK as a string
open var sdkVersion: String {
@objc open var sdkVersion: String {
guard let version = Bundle(for: Configuration.self).object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else {
return "Unknown"
}
Expand All @@ -184,7 +184,7 @@ private let callbackURIStringKey = "URIString"
/**
Resets all of the Configuration's values to default
*/
open static func restoreDefaults() {
@objc open static func restoreDefaults() {
shared = Configuration()
}

Expand All @@ -196,7 +196,7 @@ private let callbackURIStringKey = "URIString"

- returns: The string to use for the Callback URI
*/
open func getCallbackURIString() -> String {
@objc open func getCallbackURIString() -> String {
return getCallbackURIString(for: .general)
}

Expand All @@ -211,7 +211,7 @@ private let callbackURIStringKey = "URIString"

- returns: The callbackURIString for the the requested type
*/
open func getCallbackURIString(for type: CallbackURIType) -> String {
@objc open func getCallbackURIString(for type: CallbackURIType) -> String {
if callbackURIs[type] == nil {
let defaultCallbacks = parseCallbackURIs()
var fallback = defaultCallbacks[type] ?? callbackURIs[.general]
Expand All @@ -235,7 +235,7 @@ private let callbackURIStringKey = "URIString"

- parameter callbackURIString: The callback URI String to use
*/
open func setCallbackURIString(_ callbackURIString: String?) {
@objc open func setCallbackURIString(_ callbackURIString: String?) {
setCallbackURIString(callbackURIString, type: .general)
}

Expand All @@ -249,7 +249,7 @@ private let callbackURIStringKey = "URIString"
- parameter callbackURIString: The callback URI String to use
- parameter type: The Callback URI Type to use
*/
open func setCallbackURIString(_ callbackURIString: String?, type: CallbackURIType) {
@objc open func setCallbackURIString(_ callbackURIString: String?, type: CallbackURIType) {
var callbackURIs = self.callbackURIs
callbackURIs[type] = callbackURIString
self.callbackURIs = callbackURIs
Expand Down
2 changes: 1 addition & 1 deletion source/UberRides/EndpointsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private enum Resources: String {
case products = "products"
case request = "requests"

fileprivate var version: String {
private var version: String {
switch self {
case .estimates: return "v1"
case .history: return "v1.2"
Expand Down
24 changes: 12 additions & 12 deletions source/UberRides/LoginButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ import UIKit
let horizontalCenterPadding: CGFloat = 50
let loginVerticalPadding: CGFloat = 15
let loginHorizontalEdgePadding: CGFloat = 15

/// The LoginButtonDelegate for this button
open weak var delegate: LoginButtonDelegate?
@objc open weak var delegate: LoginButtonDelegate?

/// The LoginManager to use for log in
open var loginManager: LoginManager {
@objc open var loginManager: LoginManager {
didSet {
refreshContent()
}
}

/// The RidesScopes to request
open var scopes: [RidesScope]
@objc open var scopes: [RidesScope]

/// The view controller to present login over. Used
open var presentingViewController: UIViewController?
@objc open var presentingViewController: UIViewController?

/// The current LoginButtonState of this button (signed in / signed out)
open var buttonState: LoginButtonState {
@objc open var buttonState: LoginButtonState {
if let _ = TokenManager.fetchToken(identifier: accessTokenIdentifier, accessGroup: keychainAccessGroup) {
return .signedIn
} else {
Expand All @@ -94,7 +94,7 @@ import UIKit

private var loginCompletion: ((_ accessToken: AccessToken?, _ error: NSError?) -> Void)?

public init(frame: CGRect, scopes: [RidesScope], loginManager: LoginManager) {
@objc public init(frame: CGRect, scopes: [RidesScope], loginManager: LoginManager) {
self.loginManager = loginManager
self.scopes = scopes
super.init(frame: frame)
Expand Down Expand Up @@ -154,9 +154,9 @@ import UIKit
uberTitleLabel.translatesAutoresizingMaskIntoConstraints = false
uberImageView.translatesAutoresizingMaskIntoConstraints = false

uberImageView.setContentHuggingPriority(UILayoutPriorityDefaultHigh, for: .horizontal)
uberTitleLabel.setContentHuggingPriority(UILayoutPriorityDefaultHigh, for: .horizontal)
uberTitleLabel.setContentHuggingPriority(UILayoutPriorityDefaultHigh, for: .vertical)
uberImageView.setContentHuggingPriority(UILayoutPriority.defaultHigh, for: .horizontal)
uberTitleLabel.setContentHuggingPriority(UILayoutPriority.defaultHigh, for: .horizontal)
uberTitleLabel.setContentHuggingPriority(UILayoutPriority.defaultHigh, for: .vertical)

let imageLeftConstraint = NSLayoutConstraint(item: uberImageView, attribute: .left, relatedBy: .equal, toItem: self, attribute: .left, multiplier: 1.0, constant: loginHorizontalEdgePadding)
let imageTopConstraint = NSLayoutConstraint(item: uberImageView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: loginVerticalPadding)
Expand All @@ -168,7 +168,7 @@ import UIKit
let imagePaddingRightConstraint = NSLayoutConstraint(item: uberTitleLabel, attribute: .left, relatedBy: .greaterThanOrEqual , toItem: uberImageView, attribute: .right, multiplier: 1.0, constant: imageLabelPadding)

let horizontalCenterPaddingConstraint = NSLayoutConstraint(item: uberTitleLabel, attribute: .left, relatedBy: .greaterThanOrEqual , toItem: uberImageView, attribute: .right, multiplier: 1.0, constant: horizontalCenterPadding)
horizontalCenterPaddingConstraint.priority = UILayoutPriorityDefaultLow
horizontalCenterPaddingConstraint.priority = UILayoutPriority.defaultLow

addConstraints([imageLeftConstraint, imageTopConstraint, imageBottomConstraint])
addConstraints([titleLabelRightConstraint, titleLabelCenterYConstraint])
Expand Down Expand Up @@ -198,7 +198,7 @@ import UIKit

//Mark: Internal Interface

func uberButtonTapped(_ button: UIButton) {
@objc func uberButtonTapped(_ button: UIButton) {
switch buttonState {
case .signedIn:
let success = TokenManager.deleteToken(identifier: accessTokenIdentifier, accessGroup: keychainAccessGroup)
Expand Down
Loading

0 comments on commit b9931d0

Please sign in to comment.