Rob*_*Rob 8 xcode swift apple-m1
我们有一个使用许多 AWS 库的项目。第一次尝试使用 carthage 构建它时,它下载了二进制文件,但根本没有构建。所以我们运行 carthage --no-use-binaries 并构建了库。
然后就会出现这个错误:
LoginService.swift:9:8: Module 'AWSMobileClient' was created for incompatible target arm64-apple-ios9.0: ..Carthage/Build/iOS/AWSMobileClient.framework/Modules/AWSMobileClient.swiftmodule/arm64.swiftmodule
Run Code Online (Sandbox Code Playgroud)
基于这个堆栈溢出线程,我们添加arm64
了模拟器的排除架构。
这使得所有 aws 代码都可以编译(是的),但是,尝试使用通过 Swift 包管理器传入的框架时会发生此错误:
[].swift:10:8: Could not find module 'Parma' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator
Run Code Online (Sandbox Code Playgroud)
所以它想要这个库的 x86 版本,但找不到它。
该应用程序现在可以在手机上运行。但当然不是模拟器。不确定是否有办法找出哪些架构是由 SPM 构建的?或控制它。在排除arm64 arch之后,我确实重置了SPM缓存。
我认为在 M1 上实现此功能的最佳解决方案是使用 XC-Frameworks。
carthage update --use-xcframeworks
这只会构建您需要的有效拱门。如果您有任何不支持 XCFrameworks 的依赖项,则必须在构建阶段运行 lipo 来删除 x86 模拟器目标。