I'm building a Swift static library with:
- Xcode 13.2 (Swift compiler 5.5.2)
- iOS Deployment target 12.0
- Build library for distribution YES
- Skip install NO
- Swift language version 5 and tried with 4.2 Dependency managed with CocoaPods:
- Japx 3.0.0
- Alamofire 5.2.2
- RxSwift
When I try to add it to an iOS project with this setup:
- Xcode 13.3 (Swift compiler 5.6)
- iOS Deployment target 12.0
- Swift language version 5 and tried with 4.2 and build I get this error:
Failed to build module 'LibraryX'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5.2 effective-4.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)', while this compiler is 'Apple Swift version 5.6 effective-4.2 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)'). Please select a toolchain which matches the SDK.
These are the headers in the .swiftinterface
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.5.2 effective-4.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 4.2 -enforce-exclusivity=checked -Onone -module-name LibraryX
Obviously if I build the project with the same compiler version or building the library with the iOS project everything works fine. But the purpose here is to release a precompiled library and not its source code.
Every time that I lookup this error online I've found "You have to set Build library for distribution to Yes"
I tried to add the source code of the static library to a new Framework project, but I get the same result.