Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 3/Xcode 8 conversion #111

Closed
wants to merge 3 commits into from
Closed

Swift 3/Xcode 8 conversion #111

wants to merge 3 commits into from

Conversation

long
Copy link

@long long commented Sep 20, 2016

Ran the conversion to Swift 3.0 against a current project using the UberRides Cocoapod. Starting point was the swift-3-dev branch.

Updated ObjectMapper spec to ~> 2.0 to have the Swift 3 version of the dependency.

Objects with type Mappable were updated to to require the named parameter and not '_' in order to match specifications in the current version of ObjectMapper

After porting the source code, the project in this repo and test files were converted in Xcode to Swift 3.0 but not built/tested

@long long changed the title Swift 3 dev Swift 3/Xcode 8 conversion Sep 20, 2016
@long
Copy link
Author

long commented Sep 20, 2016

Project using Cocoapod builds cleanly and is able to access Uber app with the specified destination (functionality used in project app)

@jbrophy17
Copy link
Contributor

Thanks for the PR! I'll go ahead and take a look at this, but before I can merge anything, could you sign the Uber CLA?

@kwstasna
Copy link

I got your branch and it worked for a simple app of mine. Just to open UBER with 2 locations etc. Nice work!!!

@nbgraham
Copy link

@long Thanks! This saved me a lot of headache trying to convert it myself. Now it builds successfully and runs correctly.

I had some trouble figuring out how to use @long 's version of the code in my XCode project. Here's what I did:

  1. Clone @long 's fork of uber/rides-ios-sdk
    git clone https://github.com/long/rides-ios-sdk.git
  2. Switch to the swift-3-dev branch
    cd rides-ios-sdk
    git branch swift-3-dev
  3. Switch to your Xcode project directory.
  4. Set up Cocoapods.
    pod init
  5. Add UberRides to your Podfile, pointing to your local version (from Step 1; Mine was in ~/Developer/rides-ios-sdk)
    pod 'UberRides', :path => '~/Developer/rides-ios-sdk'
  6. Install and update your pods.
    pod install
    pod update
  7. Rebuild your project!

@kwstasna
Copy link

@nbgraham Or you can do
pod 'UberRides', :git => 'https://github.com/long/rides-ios-sdk.git', :branch => 'swift-3-dev’

Inside your podfile and you will avoid 6 steps! 💃

@nbgraham
Copy link

@kwstasna Thanks, that's a lot better.

I got a lot of build errors the first time, until I used XCode 8 migration tool Edit -> Convert -> To Current Swift Syntax…

Then it said no update necessary, and I rebuilt to get it working.

Why doesn't it work straight away?

@kwstasna
Copy link

@nbgraham I really don't know. I can't reproduce because as soon as I installed the pod as I told you above, I got no errors from Uber Rides!

@jbrophy17
Copy link
Contributor

@long Again thanks for this PR, but I need you to sign the Uber CLA before I can merge this in

Copy link
Contributor

@jbrophy17 jbrophy17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of my comments are just nits, but the big issue is that the tests don't compile.
Seems like a lot of the Enum renaming didn't get reflected in the test cases

fileprivate var waitingOnSystemPromptResponse = false
fileprivate var checkingSystemPromptResponse = false
fileprivate var promptTimer: Timer?
fileprivate var completionWrapper: ((NSError?) -> ()) = { _ in }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of these can stay as private

}

completionWrapper(error)
}

//Mark: App Lifecycle Notifications

@objc private func appWillResignActiveHandler(notification: NSNotification) {
@objc fileprivate func appWillResignActiveHandler(_ notification: Notification) {
Copy link
Contributor

@jbrophy17 jbrophy17 Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the functions below can be regular private as well

fileprivate static var defaultAccessTokenIdentifier: String?
fileprivate static var region : Region = .default
fileprivate static var isSandbox : Bool = false
fileprivate static var useFallback: Bool = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these fileprivate can be private

@@ -417,15 +417,15 @@ import WebKit

// MARK: Private

private static func getPlistDictionary() -> [String : AnyObject]? {
guard let path = bundle.pathForResource(plistName, ofType: "plist"),
fileprivate static func getPlistDictionary() -> [String : AnyObject]? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and those below can be private

var loginQuery = baseLoginQuery(clientID, redirect: redirect, scopes: scopes)
let additionalQueryItems = queryBuilder(("response_type", "token"))

loginQuery.appendContentsOf(additionalQueryItems)
loginQuery.append(contentsOf: additionalQueryItems)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above you changed this to += additionalQueryItems, can we do that here too?

private func getImage(name: String) -> UIImage {
let bundle = NSBundle(forClass: RideRequestButton.self)
let image = UIImage(named: name, inBundle: bundle, compatibleWithTraitCollection: nil)
fileprivate func getImage(_ name: String) -> UIImage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be private

@@ -481,7 +481,7 @@ struct ButtonMetadata {
var dropoffLatitude: Double?
var dropoffLongitude: Double?
var timeEstimate: TimeEstimate?
private var priceEstimateList: [PriceEstimate]?
fileprivate var priceEstimateList: [PriceEstimate]?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priceEstimateList

}
}

// MARK: Private

private func initialSetup() {
fileprivate func initialSetup() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be private


setupWebView()
}

private func setupWebView() {
fileprivate func setupWebView() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be private

fileprivate var accessTokenWasUnauthorizedOnPreviousAttempt = false
fileprivate var accessTokenIdentifier: String
fileprivate var keychainAccessGroup: String
fileprivate var loginCompletion: ((_ accessToken: AccessToken?, _ error: NSError?) -> Void)?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loginCompletion can be private

@jbrophy17
Copy link
Contributor

Also, @long you need you to sign the Uber CLA before I can merge this

@long
Copy link
Author

long commented Oct 4, 2016

Sorry, I hadn't logged into github directly for a bit and hadn't received email notifications.

I've just signed the Uber CLA

@jbrophy17
Copy link
Contributor

Hey @long, have you had a chance to look at my comments on your PR? Would love to get this merged!

@vinayjn
Copy link

vinayjn commented Mar 28, 2017

@jbrophy17 when are you planning to release the Swift 3 SDK, with the release of Xcode 8.3, I cannot build the SDK with Swift 2.3.

@vinayjn
Copy link

vinayjn commented Jun 14, 2017

Really sad to see inactive development for this SDK. Swift 4 is released and the SDK is still not updated for Swift 3.

@arogal
Copy link

arogal commented Jun 14, 2017 via email

@edjiang
Copy link
Contributor

edjiang commented Jul 6, 2017

Closing since it looks like the bulk of the migration was taken care of in 892a779

Sorry this took so long, and thank you @long for all of your help here :)

cc @vinayjn since you were asking for updates :)

See #167 for installing the Swift 3 package via your package manager.

@edjiang edjiang closed this Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants