Module compiled with Swift 5.0 cannot be imported by the Swift 5.1 compile

I've compiled a bunch of frameworks, Bond, and some others, using Xcode 10.2.1. When I try to run the project in Xcode 11, I get the error message `Module compiled with Swift 5.0 cannot be imported by the Swift 5.1 compiler`. I thought that moving to swift 5.0 meant we got ABI and shouldn't have to rebuild everything with the new compiler. Did I miss a setting when I ran my builds or somthing? or is this an Xcode 11 Beta bug?

Replies

We have the same issue. We can't import framework compiled with Swift 5 in Xcode 11 with swift 5.1.

Swift 5.0 does provide ABI stability, but that alone is not enough to ship pre-compiled libraries. You also need module stability so that different versions of the Swift compiler can understand the public API interface to your library, which is not available in Swift 5.0. Please see the Swift blog for more details.

This is of course been an issue with each release of Swift. You can install the Swift 5 toolchain and then use that along with Xcode 10.2 command line tools, which allows you to compile in Xcode 11 using Swift 5 instead of 5.1. However, when running in iOS 13 (or 12.1) simulator you get a runtime error like this:


dyld: Symbol not found: _OBJC_CLASS_$__TtCs12_SwiftObject
  Referenced from: ~/Library/Developer/CoreSimulator/Devices/CAAB28E5-9B4A-41A3-ADED-A481A62842BA/data/Containers/Bundle/Application//Frameworks/PhoneNumberKit.framework/PhoneNumberKit
  Expected in: /Library/Developer/Toolchains/swift-5.0.1-RELEASE.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib
 in ~/Library/Developer/CoreSimulator/Devices/CAAB28E5-9B4A-41A3-ADED-A481A62842BA/data/Containers/Bundle/Application//Frameworks/PhoneNumberKit.framework/PhoneNumberK

Any idea on how to solve this? Is this just an issue with the Xcode 11 beta?

Sorry, this is a question post, not an answer reply.

What's a standard way to fix this issue? Or how to rebuild all dependencies?


Based on my research, a lot of answers said to run : carthage update --platform iOS --no-use-binaries

Unfortunately we are not using carthage to manage our frameworks and modules, so we can't use this.

Any other solution to solve this problem?


For example, one of my error message is:


module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler: /Users/...blahblahblah.../lib/Nativform/Nativform.framework/Modules/Nativform.swiftmodule/x86_64.swiftmodule


Thanks in advance!

Hi guys,


I honestly don't know if this is the solution to what you have, but (and this applies when you are using `carthage`) if you run into this issue and you have installed both `xcode.app` and `xcode-beta.app` the best thing to do is to switch your command line tools to use the beta to build the framework.


For instance, imagine you have `alamofire` in your cartfile as follows:

github "Alamofire/Alamofire" ~> 4.8.0

Then you can configure your terminal with

sudo xcode-select -s /Applications/Xcode-beta.app


Then run carthage update

carthage update --platform iOS


The new framework shouldn't have any issues with your app compiled in Swift 5.1 (which effectively is recompiling the framework). I ran into this problem and decided to just recompile what I need and move on. Did any of you have other workarounds?

I have the same issue.

For anyone running into this due to using a beta version of Xcode, try switching the command line tools to the Xcode beta's toolchain:
`sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer` (substituting the path where you installed Xcode)

And the rebuild your dependencies (i.e. `pod install`/`carthage update`/`swift package update`). In my case I also manually removed the built dependency files because Carthage didn't correctly update them.

They are 2 different things. ABI and Modul stability. At the moment there is no Modul stability. The Modul stability it's self is starting from Swift 6 upwards and it will compatible with next version

Same issue here.


In

Xcode 11.0

Build version 11A420a

The same issue here, don't even know how to adress this the best, as we build a framework that we sell and want to allow customers (developers) to be able to use either Swift 5.0.1 (and Xcode 10) or 5.1 (and Xcode 11) as they have their own requests/timeline for upgrading... We are considering releasing multiple packages - one for each supported Swift version - but it's something that is not going to be good for the long term. (Hopefully Swift 6 would end this charade, though...)

As andrewtheis mentioned above we've also tried the "solution" of downloading and using Swift 5.0.1 toolchain (thinking that we could tell our customers to do it as well, at least for now, if they switched to Xcode 11 but can still use Swift 5.0 for a while), but... "dyld: Symbol not found: _OBJC_CLASS_$__TtCs12_SwiftObject" anyway.

Unless you need Swift 5.1 or something specific to Xcode 11, I'd recommend staying on Xcode 10.x and moving over device support files so you can debug on iOS 13 devices.


Just move everything you want from


/Applications/{XCODE11}.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/


to


/Applications/{XCODE10}.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/

We have the same issue. `Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.3.2 compiler: Publitio.framework