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 toYes
- set the
Skip Install
property toNo
. - 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/
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
Finish All Asynchronous Requests Before Loading Data
Xcode - Ld: Library Not Found for -Lpods
What Is the Height of Iphone's Onscreen Keyboard
Drawing Class Drawing Straight Lines Instead of Curved Lines
Presenting a Uialertcontroller Properly on an iPad Using iOS 8
Loading an Image into Uiimage Asynchronously
How to Use Nslocalizedstring Function with Variables in Swift
Combine Framework: How to Process Each Element of Array Asynchronously Before Proceeding
Nscamerausagedescription in iOS 10.0 Runtime Crash
Uigesturerecognizer and Uitableviewcell Issue
Change Language in the App Programmatically in iOS
How to Correctly Handle Weak Self in Swift Blocks with Arguments
Comparing Nsdates Without Time Component
Undefined Symbols for Architecture X86_64 on Xcode 6.1
Get Last Image from Photos.App
How to Rotate Text for Uibutton and Uilabel in Swift
Class Amsupporturlconnectiondelegate Is Implemented in Both
Does H.264 Encoded Video with Bt.709 Matrix Include Any Gamma Adjustment