Upload
key-hui
View
23
Download
0
Embed Size (px)
Citation preview
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.
Case Study
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.)
Big Project Size
Over ~1,000 swift code files
Slow compiling time in Swift
Average 20 mins for simulator debug build
40 mins ~ 50 mins for release build
It is terrible!
slow down development process seriously
OK. we are going to upgrade the project next.
What happen if we click the “Convert” button?
Unlimited errors are waiting for
you to fix!
Issue 1: Project settings error
Compile error about cocoapods library, legacy swift error
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
Issue 2: Looping compiling error
Fix one red error introduce another error show in other place.
Some errors didn’t show up after compilation.
Fix: Tick “Continue building after errors”
Issue 3: XCode bug
XCode sometimes missing to display red error lines when you are fixing bug
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.
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.
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.
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.
Thanks!