简体   繁体   English

如何在英特尔 mac 上支持 iOS 模拟器的 M1 mac 上构建 static 库?

[英]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我的问题是

  • how to build a static library on M1 mac that supports iOS simulator of Intel Mac?如何在支持 Intel Mac 的 iOS 模拟器的 M1 mac 上构建 static 库?
  • Or was my thinking wrong from the beginning?还是我一开始的想法就错了?

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.

相关问题 Flutter 不会在 M1 Mac 上使用 Firebase 构建在 iOS 上 - Flutter will not build on iOS with Firebase on M1 Mac Flutter iOS Z1BDF 上的应用程序605991920DB11CBDF8508204C4EBZ 在 M1 Mac 上运行的模拟器 - Flutter iOS App on an iOS Simulator running on an M1 Mac 如何在 M1 mac 中删除 iOS 模拟器 - How to delete the iOS simulators in M1 mac React Native iOS 构建失败 - Mac M1 - React Native iOS build fails - Mac M1 在 mac mini m1 主机上使用 bazel 构建 ios - Build ios with bazel on mac mini m1 hosted machine 如何检测 iOS 应用程序是否在 M1 mac 上运行? - How to detect if an iOS app is running on an M1 mac? Flutter iOS 在 iPhone 11 模拟器上运行应用程序,Mac M1 结果 CocoaPods 错误 - Flutter iOS run app on iPhone 11 simulator with Mac M1 results CocoaPods error iOS XCode 构建错误(颤振)- 无法在带有 M1 芯片的 Mac 上为 iOS(颤振)构建 apk - iOS XCode build error (flutter) -- cannot build apk for iOS (flutter) on mac with M1 chip Xcode 错误“为 iOS 模拟器构建,但在为 iOS.. 构建的 dylib 中链接”来自 Apple Silicon M1 Mac - Xcode error 'building for iOS Simulator, but linking in dylib built for iOS .. for architecture arm64' from Apple Silicon M1 Mac 如何检查lib(静态或动态)库是为iOS模拟器或Mac OSX构建的 - How to check a lib (static or dynamic) is built for iOS simulator or Mac OSX
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM