How to compile modules with Swift 2.3 and 3.0?

I upgraded to Xcode 8 and converted to the new Swift 3.0 syntax. I have a number of Cocoapods in my project, and some on Swift 2.3 (for example, some old pods require Alamofire to install v3.5, which runs Swift 2.3).

I installed these Pods to use Legacy Swift -> Yes, but when I create, I get an error:

Module complied with Swift 2.3 cannot be imported in Swift 3.0: /Users/....XSDK/XSDK.framework/swiftmodule/x86_64.swiftmodule 

I do not use Carthage (mentioned in other issues). Cocoapods only.

Do I need to convert my project to use Swift 2.3? Or can I use Swift 3.0 in my project and still use legacy Cocoapods?

+5
source share
2 answers

Unfortunately, since Swift is not an ABI Stable, you cannot combine pods like this. The reason for this is that theres a huge fast standard library that all fast pods (and frameworks, dylibs, .a, .o, etc.) should be referenced after compilation. the standard library depends on the language level, and you cannot include multiple instances of the fast standard libraries in one application.

It has been several months since Quick 3. was released. At the moment, you probably want to jump to 3. If you find a pod that has not been updated to speed 3, perhaps fork it and update it and send it to pr. The author will love you! :)

+1
source

To get the obsolete coco-capodes working in your project, you need to perform two steps.

1) Examine cocoapod and make sure that you are installing the correct version of cocoapod, which may not be the last, or may be on a separate branch, for example.

 $pod 'Your Cocoapod', :git => 'https://github.com/.....', :branch => 'branch_name' 

2) In the subcode, install the Swift version. You can also do this manually in the build settings of each module, but this code installs it automatically.

 post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '2.3' # or '3.0' #config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO' end end end 
0
source

All Articles