React Native on Apple Silicon M1 - The linked library 'libPods-ProjectName.a' is missing one or more architectures required by this target: x86_64

僤鯓⒐⒋嵵緔 提交于 2020-12-30 02:44:06

问题


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

The project built nicely on Intel architecture.

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

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

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

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

Now I have:

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

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

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


回答1:


I had the same issue and finally, I fix it. there are 2 main reasons for errors

  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.

2.Because the Valid Architectures build setting being removed in Xcode 12, So Project file open in Xcode 12 will auto-generate a VALID_ARCHS macro in User-Defines, and this macro will make the build failed.

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

final step was updating all pods by running below command inside ios folder :

pod deintegrate

pod update

then I exclude arm64 for simulator architecture both from your main Project and the Pod project. enter image description here

clean project (shift +command +k) then run



来源:https://stackoverflow.com/questions/65364886/react-native-on-apple-silicon-m1-the-linked-library-libpods-projectname-a-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!