我正在用以下工具构建一个Swift静态库:
YES
管理的4.2依赖项
当我尝试使用此设置将其添加到iOS项目时:
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.这些是.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显然,如果我用相同的编译器版本构建项目,或者用iOS项目构建库,一切都很好。但是这里的目的是发布预编译库,而不是它的源代码。
每次在网上查找此错误时,我都会发现“您必须将发行版的构建库设置为Yes”。
我试图将静态库的源代码添加到一个新的Framework项目中,但是我得到了相同的结果。
发布于 2022-07-20 21:49:05
我也有这个错误,在我的例子中,是在读取文件时无法导入XCFramework的子依赖项.swiftinterface,但是它显示的绝对是误导性错误。
在反复清理DerivedData并尝试不同的Xcode版本(13.0,13.4.1)之后,我看到了两个错误:“编译器不支持此SDK”,以及“没有模块名为'AnotherLib'”,这是我的Swift包中错误指定的依赖项。
因此,可能只有消息的第一部分是正确的“未能构建模块'LibraryX'",但原因是其他原因,而不是编译器版本的差异。
https://stackoverflow.com/questions/71659085
复制相似问题