I have a project with a light amount of code written in what I assume is swift 2.3 It contains and app extension also written in swift 2.3 and uses 2 Cocoapods: SwiftyJSON and MMWormhole. After downloading Xcode 8.3 beta, the migrator ran and I am left with almost 100 compiler errors in the one main swift file contained in SwiftyJSON.
Basically I want to know if there is a way I can work in Xcode8 given these details. I am happy to update my own code to swift3 however I do not control the cocoapods (MMWormHole is in objective-C so I assume that Xcode converts that to whichever version of Swift it needs as it emits no compiler errors). Can I tell Xcode to use swift 2.3 globally?
You have to set Use Legacy Swift Language Version to YES to make use SWIFT 2.3 code in Xcode 8. Then add this into your Podfile to make all of your pod targets confirm the same.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
configuration.build_settings['SWIFT_VERSION'] = "2.3"
end
end
end
I hope, it will help.
Many open source Swift projects have branches for Swift 3 or Swift 2.3 (see this post for details on a popular approach). I checked SwiftyJSON and it appears to have a branch for Swift 3, so you could convert your app to Swift 3 and give that a try. In order to use it, change the SwiftyJSON entry in your Podfile to:
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'swift3'
It's up to the project to update for each Xcode 8 beta, so it may not be exactly working, but it is likely that there will be fewer than 100 errors.
Note: You may see a “Use Legacy Swift Language Version” error after updating everything and fixing the complier errors. This can be fixed by adding a post_install step to your Podfile (see this GitHub issue), or by updating to CocoaPods 1.1.0.beta.1 or higher (gem install cocoapods --pre).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With