在 Apple Silicon M1 上 React Native - 链接库“libPods-ProjectName.a"缺少此目标所需的一个或多个架构:x86_64 [英] React Native on Apple Silicon M1 - The linked library 'libPods-ProjectName.a' is missing one or more architectures required by this target: x86_64

查看:48
本文介绍了在 Apple Silicon M1 上 React Native - 链接库“libPods-ProjectName.a"缺少此目标所需的一个或多个架构:x86_64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在具有 M1 架构的 MacBook Pro 上为 iOS 模拟器构建一个 React Native 项目.

I'm trying to build a React Native project on a MacBook Pro with a M1 architecture, for iOS simulator.

该项目很好地构建在英特尔架构上.

The project built nicely on Intel architecture.

它也在设备上构建并在 M1 上很好地存档.但不是在模拟器上.

It also build on device and archive well on M1. But not on simulator.

我在切换到 M1 芯片组时遇到了这个经典错误.

I had this classical error when switching to the M1 chipset.

在/project-folder/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(cryptlib.o)中,为iOS模拟器构建,但在为iOS构建的目标文件中链接,文件'/project-folder/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a' 用于架构 arm64

in /project-folder/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(cryptlib.o), building for iOS Simulator, but linking in object file built for iOS, file '/project-folder/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a' for architecture arm64

我将 arm64 添加到排除的架构中.

I added arm64 to excluded architectures.

我还添加了以下代码段,但如果没有它,它也会以相同的方式做出反应.

I also added the following snippet but it also react the same way without it.

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

现在我有:

/project-folder/ios/ProjectName.xcodeproj 链接库libPods-ProjectName.a"缺少此目标所需的一个或多个架构:x86_64.

/project-folder/ios/ProjectName.xcodeproj The linked library 'libPods-ProjectName.a' is missing one or more architectures required by this target: x86_64.

我尝试将 x86_64 添加到项目的架构列表中,但没有结果.

I tried to add x86_64 on the list of architectures of the project, with no results.

我是从 Xcode IDE 构建的.对于我尝试过的所有 iPhone:8、11、12 以及我尝试过的所有目标:iOS 9、10 和 13,都会出现此错误消息.

I'm building from Xcode IDE. This error message appears for all iPhones I tried: 8, 11, 12 and all targets I tried: iOS 9, 10 and 13.

推荐答案

我遇到了同样的问题,最后我修复了它.出现错误的主要原因有两个:

I had the same issue and finally, I fixed it. There are 2 main reasons for the errors:

  1. arm64 架构支持 &许多流行的第三方库(如 Firebase、AFNetworking 等)尚未提供与 Xcode 12 兼容的版本.Xcode 11 曾经自动将模拟器的 arm64 编译转换为 x86_64 编译,但现在 arm64 是一个有效的模拟器架构(它是 Apple Silicon 架构),该转换不再发生.

  1. arm64 architecture support & and Xcode 12 compatible version have not been provided by many popular third party libraries yet (like Firebase, AFNetworking, etc). Xcode 11 used to automatically translate building for arm64 for the simulator into building for x86_64, but now that arm64 is a valid simulator architecture (it’s the Apple Silicon architecture), that translation no longer occurs.

因为 Valid Architectures 构建设置已从 Xcode 12 中删除,在 Xcode 12 中打开的项目文件将在用户定义中自动生成一个 VALID_ARCHS 宏,这个宏会使构建失败.

Because the Valid Architectures build setting has been removed from Xcode 12, the Project file, opened in Xcode 12, will auto-generate a VALID_ARCHS macro in User-Defines, and this macro will make the build fail.

我按照这篇文章中的所有步骤进行操作:https://medium.com/@khushwanttanwar/xcode-12-compilation-errors-while-running-with-ios-14-simulators-5731c91326e9

I follow all steps in this post: https://medium.com/@khushwanttanwar/xcode-12-compilation-errors-while-running-with-ios-14-simulators-5731c91326e9

最后一步是通过在项目文件夹中运行以下命令来更新所有 Pod:

Final step was updating all pods by running below command inside the project folder:

pod deintegrate
pod update

然后我从主项目和 Pod 项目中排除了模拟器架构的 arm64.

Then I exclude the arm64 for the Simulator architecture, both from main project and the Pod project.

清理项目( + + k)然后运行.

Clean the project ( + + k) then run.

这篇关于在 Apple Silicon M1 上 React Native - 链接库“libPods-ProjectName.a"缺少此目标所需的一个或多个架构:x86_64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆