Swift编译器版本冲突:Xcode14.2下无法构建Smile_Identity_SDK
Swift版本冲突问题
当前环境配置
- Xcode版本:14.2(Swift编译器5.7.2)
- iOS部署目标:16.2
- 已启用
Build library for distribution选项 - 已将Package的
swift-tools-version设置为5.7.1
Package配置代码
// swift-tools-version: 5.7.1 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "SmileIDentity", platforms: [.iOS(.v16)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SmileIDentity", targets: ["SmileIDentity", "Smile_Identity_SDK"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), ], targets: [ .target( name: "SmileIDentity", dependencies: []), .binaryTarget(name: "Smile_Identity_SDK", path: "./Smile_Identity_SDK.xcframework"), .testTarget( name: "SmileIDentityTests", dependencies: ["SmileIDentity"]), ] )
报错信息
Failed to build module 'Smile_Identity_SDK'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)', while this compiler is 'Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)'). Please select a toolchain which matches the SDK.
错误说明
无法构建模块Smile_Identity_SDK,该SDK由Apple Swift 5.7.1版本编译,当前编译器为Apple Swift 5.7.2版本,需使用与SDK匹配的工具链。
解决方法
- 切换Xcode版本:Swift 5.7.1对应Xcode 14.1版本,下载安装Xcode 14.1并切换至该版本,重新构建项目。
- 更新SDK版本:联系SDK提供商,获取适配Swift 5.7.2(Xcode 14.2)的
Smile_Identity_SDK版本,替换现有xcframework后重新编译。 - 调整工具链:在Xcode的
设置 > 位置 > 命令行工具中选择Xcode 14.1对应的工具链,确保编译器版本与SDK匹配。
注意:swift-tools-version仅声明构建Package的最低Swift版本,无法解决预编译二进制框架与当前编译器的版本冲突问题,开启Build library for distribution后版本兼容性要求会更严格。
内容的提问来源于stack exchange,提问作者Darotudeen
相关产品推荐
相关产品推荐

