Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Migration to Swift 3: CocoaCoders Austin 2017-03-23

Migration to Swift 3: CocoaCoders Austin 2017-03-23

Overview of steps needed to migrate from Objective-C or earlier Swift to Swift 3.
Example of a migration of a small Objective-C project from 2012 to Swift 3.

Patrick Weigel

March 23, 2017
Tweet

More Decks by Patrick Weigel

Other Decks in Programming

Transcript

  1. Migration to Swift 3 1. 3 > 2 2. Swift

    4 will attempt to not break Swift 3 3. Xcode 8.3+ will not support Swift 2.3 Xcode 8.3 coming soon: ß5 is available 2017-03-21 Xcode 8.3 ß5 is version 8.3 (8E161), no beta in name Cocoa Coders 2017-03-23 Migration to Swift 3 Why
  2. Migration to Swift 3 1. Steps for successful migration (14

    slides) 2. Example of successful migration (12 slides plus live code) Cocoa Coders 2017-03-23 Migration to Swift 3 Overview
  3. Migration to Swift 3 1. Understand Swift 3 and its

    idioms 2. Learn from others’ migrations 3. Decide on migration path 4. Migrate Cocoa Coders 2017-03-23 Migration to Swift 3 Steps For A Successful Migration
  4. Migration to Swift 3 Apple Swift 3.1: https://swift.org/documentation/#the-swift- programming-language (10

    hours) Apple Swift 3.0.1: https://developer.apple.com/library/content/ documentation/Swift/Conceptual/Swift_Programming_Language/ (10 hours) Apple Overview: https://developer.apple.com/swift/ (< 1 hour) Cocoa Coders 2017-03-23 Migration to Swift 3 Understand Swift 3 (1 of 2)
  5. Migration to Swift 3 WWDC 2016 402: https://developer.apple.com/videos/play/ wwdc2016/402/ (1

    hour) Hacking: https://www.hackingwithswift.com/swift3 (1 hour) Swift.org: https://swift.org/blog/swift-3-0-released/ (<1 hour) Cocoa Coders 2017-03-23 Migration to Swift 3 Understand Swift 3 (2 of 2)
  6. Migration to Swift 3 1. Understand Swift 3 and its

    idioms 2. Learn from others’ migrations 3. Decide on migration path 4. Migrate Cocoa Coders 2017-03-23 Migration to Swift 3 Steps For A Successful Migration ✔
  7. Migration to Swift 3 OVERVIEWS Swift.org: https://swift.org/migration-guide/ Wenderlich: https://www.raywenderlich.com/135655/whats-new-swift-3 reddit:

    https://www.reddit.com/r/swift/comments/53ebke/ any_lessons_learned_migrating_to_swift_3_and_how/#bottom-comments Cocoa Coders 2017-03-23 Migration to Swift 3 Learn From Others (1 of 3)
  8. Migration to Swift 3 MULTI-DEVELOPER SHOPS Airbnb: https://medium.com/airbnb-engineering/getting-to-swift-3-at- airbnb-79a257d2b656#.drj1ho8uc Possible

    Mobile: https://possiblemobile.com/2016/12/great-swift-3-migration/ Nextdoor: https://engblog.nextdoor.com/migrating-to- swift-3-7add0ce0655#.f5t2awk1w Cocoa Coders 2017-03-23 Migration to Swift 3 Learn From Others (2 of 3)
  9. Migration to Swift 3 SINGLE DEVELOPER SHOPS Jesse Squires: http://www.jessesquires.com/migrating-to-swift-3/

    Chris Hulbert: http://www.splinter.com.au/2016/11/06/swift-3-migration/ Cocoa Coders 2017-03-23 Migration to Swift 3 Learn From Others (3 of 3)
  10. Migration to Swift 3 1. Understand Swift 3 and its

    idioms 2. Learn from others’ migrations 3. Decide on migration path 4. Migrate Cocoa Coders 2017-03-23 Migration to Swift 3 Steps For A Successful Migration ✔ ✔
  11. Migration to Swift 3 Answer Me These Questions Six: 1.

    Migrate from What to What? Objective-C, Swift 1, Swift 2.2, Swift 2.3 2. Freeze code or migrate while enhancing? 3. Migrate to Literal Swift 3 or Idiomatic Swift 3? 4. Simultaneous refactoring and other code improvements? 5. git branching scheme? 6. What does failure look like? Cocoa Coders 2017-03-23 Migration to Swift 3 Decide on Migration Path
  12. Migration to Swift 3 1. Understand Swift 3 and its

    idioms 2. Learn from others’ migrations 3. Decide on migration path 4. Migrate Cocoa Coders 2017-03-23 Migration to Swift 3 Steps For A Successful Migration ✔ ✔ ✔
  13. Migration to Swift 3 This is the first time you

    should have opened your code 1. Migrate dependencies (CocoaPods,Carthage, git submodules) 2. Create dependency graph of classes https://github.com/vampirewalk/ObjectGraph-Xcode 3. Migrate starting at leaf classes 4. Monitor .ipa size, compile time Cocoa Coders 2017-03-23 Migration to Swift 3 Migrate (1 of 3)
  14. Migration to Swift 3 Migrate Leaf Class 1. Translate code

    (possibly via https://objectivec2swift.com/#/home/main) 2. Eliminate translation errors 3. Eliminate other errors 4. Eliminate warnings (let / var) 5. Hook up new Swift code Cocoa Coders 2017-03-23 Migration to Swift 3 Migrate (2 of 3)
  15. Migration to Swift 3 1. Unit tests 2. QA 3.

    Phase 2.1: Swift Warnings 4. Phase 2.2: Migrate to Idiomatic Swift Cocoa Coders 2017-03-23 Migration to Swift 3 Migrate (3 of 3)
  16. Migration to Swift 3 1. Understand Swift 3 and its

    idioms 2. Learn from others’ migrations 3. Decide on migration path 4. Migrate Cocoa Coders 2017-03-23 Migration to Swift 3 Steps For A Successful Migration ✔ ✔ ✔ ✔
  17. Migration to Swift 3 Answer Me These Questions Six: 1.

    Migrate from What to What? Objective-C, Swift 1, Swift 2.2, Swift 2.3 2. Freeze code or migrate while enhancing? 3. Migrate to Literal Swift 3 or Idiomatic Swift 3? 4. Simultaneous refactoring and other improvements? 5. git branching scheme? 6. What does failure look like? Cocoa Coders 2017-03-23 Migration to Swift 3 Decide on Migration Path
  18. My Answers: 1. Migrate from Objective-C directly to Swift 3.0

    2. Freeze code 3. Migrate to Literal Swift 3 4. No simultaneous refactoring or other improvements 5. git branching scheme: “Plow Forward Blindly” 6. Failure will be an amusing anecdote Cocoa Coders 2017-03-23 Migration to Swift 3 Decide on Migration Path Example Migration to Swift 3
  19. 1. Translate code (possibly via https://objectivec2swift.com/#/home/main) 2. Eliminate translation errors

    3. Eliminate other errors 4. Eliminate warnings (let / var) 5. Hook up new Swift code Cocoa Coders 2017-03-23 Migration to Swift 3 Example Migration to Swift 3
  20. Cocoa Coders 2017-03-23 Migration to Swift 3 Example Migration to

    Swift 3 after https://objectivec2swift.com/#/home/main
  21. 1. Translate code (possibly via https://objectivec2swift.com/#/home/main) 2. Eliminate translation errors

    3. Eliminate other errors 4. Eliminate warnings (let / var) 5. Hook up new Swift code Cocoa Coders 2017-03-23 Migration to Swift 3 ✔ ✔ ✔ ✔ Example Migration to Swift 3
  22. Migration to Swift 3 1. 3 > 2 2. Swift

    4 will attempt to not break Swift 3 3. Xcode 8.3+ will not support Swift 2.3 Xcode 8.3 coming soon: ß5 is available 2017-03-21 Xcode 8.3 ß5 is version 8.3 (8E161), no beta in name Cocoa Coders 2017-03-23 Migration to Swift 3 Why