20
Tips for Migration from Swift 2.2 to Swift 3.0

Tips for migration from swift 2.2 to swift 3.0

  • Upload
    key-hui

  • View
    23

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Tips for migration from swift 2.2 to swift 3.0

Tips for Migration from Swift 2.2 to

Swift 3.0

Page 2: Tips for migration from swift 2.2 to swift 3.0

Swift 2.2 is no longer support

After Apple released XCode 8.2 in Sept 2016, swift project will need to force upgrade to Swift 2.3 or Swift 3.0

Anyway, you still can upload ipa by using XCode 7, but not guarantee you can pass Apple review approval.

Page 3: Tips for migration from swift 2.2 to swift 3.0

Case Study

Page 4: Tips for migration from swift 2.2 to swift 3.0

WalkingApp - written in swift 2.2

A bunch of third party library integrated including Objective-C, Swift and custom own library.

(Alamofire, SwiftFlux, Charts, XMPPFramework, SugarRecord, Realm, DeepLinkKit, SwaggerClient, etc.)

Page 5: Tips for migration from swift 2.2 to swift 3.0

Big Project Size

Over ~1,000 swift code files

Page 6: Tips for migration from swift 2.2 to swift 3.0

Slow compiling time in Swift

Average 20 mins for simulator debug build

40 mins ~ 50 mins for release build

Page 7: Tips for migration from swift 2.2 to swift 3.0

It is terrible!

slow down development process seriously

Page 8: Tips for migration from swift 2.2 to swift 3.0

OK. we are going to upgrade the project next.

Page 9: Tips for migration from swift 2.2 to swift 3.0

What happen if we click the “Convert” button?

Page 10: Tips for migration from swift 2.2 to swift 3.0

Unlimited errors are waiting for

you to fix!

Page 11: Tips for migration from swift 2.2 to swift 3.0

Issue 1: Project settings error

Compile error about cocoapods library, legacy swift error

Page 12: Tips for migration from swift 2.2 to swift 3.0

Fix: Add “SWIFT_VERSION” to Podfile

post_install do |installer|

installer.pods_project.targets.each do |target|

target.build_configurations.each do |config|

config.build_settings['SWIFT_VERSION'] = '3.0'

end

end

end

Page 13: Tips for migration from swift 2.2 to swift 3.0

Issue 2: Looping compiling error

Fix one red error introduce another error show in other place.

Some errors didn’t show up after compilation.

Page 14: Tips for migration from swift 2.2 to swift 3.0

Fix: Tick “Continue building after errors”

Page 15: Tips for migration from swift 2.2 to swift 3.0

Issue 3: XCode bug

XCode sometimes missing to display red error lines when you are fixing bug

Page 16: Tips for migration from swift 2.2 to swift 3.0

Issue 4: 3rd party library support

“Alamofire” 4.x only support Swift 3 and does not support iOS8

“SwiftFlux” no update to support Swift 3 yet.

“Chart” totally change source code in Swift 3.

Page 17: Tips for migration from swift 2.2 to swift 3.0

Fix: No fast solution at all

Firstly, you need to wait the source community to support Swift 3 before you start.

When you choose a 3rd party library, please pay attention to the active rate and number of stars.

Better mircoservice structures will help to debug and update for library code change.

Hint: Breakdown you big source code into many small library for specific feature.

Page 18: Tips for migration from swift 2.2 to swift 3.0

Finally

We (4 Engineers) use about 1 month to update source code from Swift 2.2 to Swift 3.0 until the build is success.

Page 19: Tips for migration from swift 2.2 to swift 3.0

Summary

Use Objective-C if you afraid of fast change open source development process.

You still can use Objective-C in the future 3 years at least.

Swift language is good, but painful when upgrading from major version each time.

It will got much stable and easy coding and maintain.

Page 20: Tips for migration from swift 2.2 to swift 3.0

Thanks!