Module Compiled with Swift 5.1 Cannot Be Imported by the Swift 5.1.2 Compiler

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler

OK, Turns out if you watch the WWDC video, they explain it:
https://developer.apple.com/videos/play/wwdc2019/416/

You need to set the Build Settings > Build Options > Build Libraries for Distribution option to Yes in your framework's build settings, otherwise the swift compiler doesn't generate the neccessary .swiftinterface files which are the key to future compilers being able to load your old library.

This ends up in your project.pbxproj file as:

BUILD_LIBRARY_FOR_DISTRIBUTION = YES;

After setting this flag, a framework I compiled using Xcode 11.0 (swift 5.1) was able to be used by Xcode 11.2 (swift 5.1.2) and everything appears to be working correctly.

Hopefully this question/answer will serve as a useful reference for everyone who hasn't watched all the WWDC videos

If the error still persists go to Product > Clean Build Folder and Build again.

Swift Module stability: Module compiled with Swift X.Y cannot be imported by the Swift X.Z compiler

You need Module Stability, not ABI stability.

The difference and the way how to achieve Module Stability, are described here: https://www.donnywals.com/what-is-module-stability-in-swift-and-why-should-you-care/

Here is WWDC session that explains swift binary frameworks (time code: 17:00).

Briefly, your framework

  • should be built with Build Libraries for Distribution set to Yes
  • set the Skip Install property to No.
  • distributed as .xcframework with variants for simulator and device

You'll need to ensure that frameworks embedded into .xcframework all have .swiftinterface file inside of Modules/.swiftmodule folder.

Module compiled with Swift 5.5.1 cannot be imported by the Swift 5.5.2 compiler RazorPay

I fixed it by adding this code into my Podfile

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end

Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler

This problem is caused by the fact that you attempt to embed a pre-compiled framework that was created with a different compiler version.

Currently, pre-compiled frameworks can only be embedded if the compiler versions match! The swift compiler version that is used to compile the project must be the same version that was used to compile the framework.

Hopefully, this restriction will be removed in future Swift / compiler versions...
For more information refer to the chapter on "Module Stability" here: https://swift.org/blog/abi-stability-and-more

As already mentioned in one of the comments, the solution to this problem is to up- or downgrade to the appropriate Xcode version. (Or, if possible, recompile the framework with the desired compiler version and then use the same compiler version for your project.)



Related Topics



Leave a reply



Submit