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

Any plan to upgrade to Swift 3? #14

Closed
lexrus opened this issue Dec 15, 2016 · 11 comments
Closed

Any plan to upgrade to Swift 3? #14

lexrus opened this issue Dec 15, 2016 · 11 comments

Comments

@lexrus
Copy link

lexrus commented Dec 15, 2016

Swift 2.3 would be deprecated in the next release of Xcode. Do you have any plan to upgrade the entire code base and dependencies?

@mbrandonw
Copy link
Contributor

Yeah for sure! It'll probably be the first thing we do in the new year. Stay tuned for the massive PR...

@evgeniyd
Copy link

@mbrandonw so, will you be doing the migration in-house and without involving open-source community?

@stephencelis
Copy link
Contributor

@evgeniyd We'll be doing the migration in the open on branches and definitely won't turn down community help! 😄

@damianesteban
Copy link

I would love to give a hand. This project is such an amazing resource.

@jorgecasariego
Copy link

Great to hear that @evgeniyd

Like @damianesteban I'd love to help in this project!

@mfclarke
Copy link
Contributor

mfclarke commented Dec 19, 2016

Volunteering to help out over here 👋

@mbrandonw
Copy link
Contributor

Hi everyone! We've begun the Swift 3 migration, and it's doozy! We don't see a clear way of sharing this work, but if yer interested in following along or critiquing our methods, here are some PR's we've done so far:

kickstarter/Kickstarter-Prelude#62
kickstarter/Kickstarter-ReactiveExtensions#54
kickstarter/ios-ksapi#3

@Iron-Ham
Copy link

Iron-Ham commented Dec 23, 2016

Hey @mbrandonw I've migrated several ~900 class Swift projects to Swift 3 in the last month or so, (also the author of https://buildingvts.com/a-mostly-comprehensive-list-of-swift-3-0-and-2-3-changes-193b904bb5b1)

I'd like to share lessons learned doing these large migrations:

  • If you use @IBAction, don't refactor your action code to look like: @IBAction func doTheThing(button: UIButton) { ... }. Leave the anonymous first parameter in the method definition.
  • Push Notifications. If you were doing something like this to convert your device token to a string (I've seen this everywhere) your pushes are going to break:
return String(data: deviceToken.base64EncodedData(), encoding: .utf8)?
             .trimmingCharacters(in: CharacterSet.whitespaces)		
             .trimmingCharacters(in: CharacterSet(charactersIn: "<>"))		
             ?? ""

Realistically, the right way is to treat PN deviceTokens as Data, but in lieu of that, here's some magic code to do it: return deviceToken.reduce("", {$0 + String(format: "%02X", $1)})

  • Networking (but really, value types). AnyObject used to be the gold standard for networking, and for any thing. That's been replaced by Any, which is no longer a representation of a type but a representation of a value. Basically, things that are class objects are AnyObject, but struct are Any. This has far reaching implications. In general, you don't want to use AnyObject unless you're communicating with an Obj-C class.

Finally, FREEZE THE WORLD. Conflicts here are neither trivial or fun. Don't spend time trying to deal with them.

@mbrandonw
Copy link
Contributor

@heshamsalman wow, thanks for all of the info! definitely the Any/AnyObject difference has definitely been the biggest gotcha we've experienced!

we just opened a PR that converts our Library.framework to Swift 3 #26, which is more than half of the app code. Still a long ways to go, but we're making progress!

@mbrandonw
Copy link
Contributor

oh, and btw @heshamsalman, this is how we do our push token transformation: https://github.com/kickstarter/ios-oss/blob/master/Kickstarter-iOS/ViewModels/AppDelegateViewModel.swift#L629-L634. That's swift 2 code, hasn't been updated to swift 3 yet. i'll keep your comments in mind when i get to that code! thanks again!

@mbrandonw
Copy link
Contributor

Hey everyone, we just completed our Swift 3 migration #26 so I'll close this one now. Thanks for the interest!

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

No branches or pull requests

8 participants