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.
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.)
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/<name>.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
Related Topics
Autolayout: Origin and Size Should Change According to Width and Height Factor
Understanding Model-View-Controller
How to Get Current Location Using Cllocationmanager in iOS
Phimageresultisdegradedkey/Phimagefileurlkey Is Not Found
iOS App Getting Throttled from Local Searches
Xcode Creates Wrong IPA Folder Structure
Custom Font Not Working in Wkwebview Swift
Reordering Uitableview Without Reorder Control
How Is Filters Uiscrollview/Uicollectionview in Apple's Photos App Implemented That It Opens So Fast
Taking Screenshots in the Background (Ios) - Improving Performance
Grouping Coredata by Date() in Swiftui List as Sections
Two Buttons Inside Hstack Taking Action of Each Other
App Is Not Showing in the Share Menu of Shared Options in Shared Extension in iOS8
Add a Navigation Bar to a View Without a Navigation Controller
Drawing Rounded Rect in Core Graphics
How to Take Uiimage of Avcapturevideopreviewlayer Instead of Avcapturephotooutput Capture