Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile modules with Swift 2.3 and 3.0?

I updated to Xcode 8 and converted to latest Swift 3.0 syntax. I have a number Cocoapods in my project, and some are on Swift 2.3 (e.g. some older pods require Alamofire set to v3.5, which runs Swift 2.3).

I have set these Pods to Use Legacy Swift -> Yes, but when building I get the error:

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

I don't use Carthage (referenced in other questions). Only Cocoapods.

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?

like image 928
hegranes Avatar asked Nov 08 '22 09:11

hegranes


1 Answers

Unfortunately as Swift is not ABI Stable, you cannot combine pods like this. The reason for this is that theres the huge swift standard library that all swift pods (and frameworks, dylibs, .a, .o, etc) need to reference once compiled. the standard library is language level dependent, and you cannot include multiple copies of the swift standard libraries in a single app.

It has been a good couple months since swift 3 was released. At this point, you're probably going to want to make the jump to 3. If you find a pod that hasn't been updated to swift 3, perhaps fork it and update it and submit a pr. The author will love you! :)

like image 91
Joe Daniels Avatar answered Nov 15 '22 05:11

Joe Daniels