[英]How to build a static library on M1 mac that supports iOS simulator on Intel mac?
I have a fat iOS library which supports both real devices (arm64...) and iOS simulator of Intel Mac (x86_64).我有一个胖 iOS 库,它支持英特尔 Mac(x86_64)的真实设备(arm64 ...)和 iOS 模拟器。 But when I switched to M1 mac, things get tough.但是当我切换到 M1 mac 时,事情变得艰难。
If I use the old library, I will fail with error saying xxx.a (xxx.o) building for iOS Simulator, but linking in object file built for iOS, file 'xxx' for architecture arm64
.如果我使用旧库,我将失败并显示xxx.a (xxx.o) building for iOS Simulator, but linking in object file built for iOS, file 'xxx' for architecture arm64
。 It seems that I have to build a xcframework which contains binaries for different destinations.看来我必须构建一个包含不同目的地的二进制文件的 xcframework。
So I tried to build different slices and hope to bundle them as a xcframework.所以我尝试构建不同的切片,并希望将它们捆绑为一个 xcframework。 But I finally found I don't know how to build the x86_64 slice with a M1 Mac.但我终于发现我不知道如何用 M1 Mac 构建 x86_64 切片。
My question is我的问题是
The reason I failed to get x86_64 slice on M1 Mac is that there is a legacy option in my build setting: Valid architectures.我未能在 M1 Mac 上获得 x86_64 切片的原因是我的构建设置中有一个旧选项:有效架构。
Remove this configuration and run standard flow.删除此配置并运行标准流程。 Then you will get library containing x86_64 architecture smoothly.然后您将顺利获得包含 x86_64 架构的库。
xcodebuild archive --destination="generic/platform=iOS Simulator" ...
If your library code is not organized as a Xcode project but uses clang toolchain underneath.如果您的库代码没有组织为 Xcode 项目,而是在下面使用 clang 工具链。 You can refer to this link .你可以参考这个链接。 In a nutshell, specify target in a format like arm64-apple-ios14.3-simulator简而言之,以 arm64-apple-ios14.3-simulator 之类的格式指定目标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.