Xcode 8.3.2 Swift 3.2 CocoaPods: 1.3.1
pod 'APIKit' pod 'Crashlytics' pod 'CryptoSwift' pod 'Fabric' pod 'Firebase/Core' pod 'Google/Analytics' pod 'GoogleIDFASupport' pod 'Himotoki' pod 'PureLayout' pod 'SDWebImage' pod 'SVProgressHUD' pod 'SwiftyRSA' pod 'TTTAttributedLabel'
Upgrade to Xcode9 (with swift3.2)
Don’t touch these, yet
Swift Conversion Convertion to Swift 4 is available
Validate Project Settings Update to recommended settings
Some Pod build will fail (CryptoSwift)
In case of CryptoSwift, it already release swift 4 support version.
'Decodable' is ambiguous for type lookup in this context`
⚠️ Please note that you should need to add the module name Himotoki to Decodable (Himotoki.Decodable) to avoid type name collision with Foundation.Decodable in Xcode 9 or later. ⚠️
As above notice, replace
I faced following error as well, and fixed with
Reference to generic type 'KeyPath' requires arguments in <...>
Upgrade to Swift 4
Execute auto conversion for only own project. (includes Tests, UITests, and Extension but NOT Pods)
According to the document,
We can choose from
- Minimize Inference
- Match Swift 3 Behavior
To activate Swift 4’s merit,
It will change
- Some Enums
@objc for method which are refered via
Then new warning
Dependency Analysis Warning The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Hopping" target.
And some deprecated warning too.
Update to recommended settings
Execute “Update to recommended settings” on own project, then it will enable some compiler warnings.
Pods/ will be excluded from version controll, so we shouldn’t execute “Update to recommended settings” for Pod project.
There is an issue on CocoaPods,
So we should wait v1.4.0
swift_version = '4.0' in Podfile
Some Pod will build fail at here as well.
In my case, SwiftyRSA failed. They already have
swift4 branch so,
pod 'SwiftyRSA', :git => 'https://github.com/TakeScoop/SwiftyRSA', :branch => 'swift4'
The use of Swift 3 @objc inference in Swift 4 mode is deprecated.
In project settings, each targets have
On, so change it to
Swift 3 @objc inference:
resolve deprecated warnings
In my case, i had only this kind of warning.
warning: 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range upto' operator.
text.substring(to: 3) text.substring(from: 3)
String(text.prefix(3)) String(text[text.index(text.startIndex, offsetBy: 3)...])
I feel this time is quite easier, compare to swift 3 migration. But I will need to adapt iPhone X as well.