jcore-react-native icon indicating copy to clipboard operation
jcore-react-native copied to clipboard

arm64架构电脑, 使用模拟器打debug版本报错

Open AlanWen2016 opened this issue 4 years ago • 3 comments

arm64架构电脑, 使用模拟器打debug版本报错 image

AlanWen2016 avatar Mar 01 '21 08:03 AlanWen2016

楼主解决了吗,同样的问题求助

Archer-Programmer avatar Jan 25 '22 09:01 Archer-Programmer

解决了吗

hutaoao avatar Aug 18 '22 09:08 hutaoao

这个问题主要是发生在苹果芯片上吧,app debug运行在arm64的虚拟机上,我找了了几个解决方案.


我自己采用的方案如下:

  • 打开xcode,打开项目的Build Settings -> Architectures -> Excluded Architectures -> Debug, 然后选择Any iOS Simulator, 并给它填上值arm64. (具体设置截图在下面)

  • 打开iOS目录下的Podfile文件,在整个文件结尾处添加如下代码:

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end
  • 重新执行pod install安装iOS依赖, 打开Xcode点击菜单中的Product,点击Clean Build Folder清一下缓存,再debug运行app应该能跑起来了。

第一点Xcode的具体设置截图如下:

Xocde Settings


具体原理就是:

这样设置后,iOS的虚拟机仍然是以arm64的方式运行,但是debug跑起来的app是以x86的方式运行,所以debug编译运行就不会报那个不支持arm64架构的错误了。Podfile那里的代码是为了让cocoapods的设置和项目的设置保持一致。

还有一个我验证了可行的方案就是把Xcode设置成以Rosetta的方式运行,但是不推荐会折损性能。

这是我的参考连接,我使用的方法是从这篇文章作者那学习的,更细节的介绍可以读一下文章。

congshengwu avatar Aug 19 '22 02:08 congshengwu