美文网首页
M1芯片simulate运行arm64与x86_64问题

M1芯片simulate运行arm64与x86_64问题

作者: HeavenWong | 来源:发表于2022-10-25 16:04 被阅读0次

问题描述: M1芯片电脑, 使用xcode模拟器simulate编译项目, 报下面错误

error build: In /xx/Pods/xx.a(xx.o), building for iOS Simulator, but linking in object file built for iOS, file '/xx/Pods/xx. a' for architecture arm64

原因: M1芯片模拟器支持架构ARM64, Intel芯片模拟器支持x86_64架构.

解决方案一

  • 模拟器运行使用arm指令, APP运行用x86_64指令

  • 添加arm64到项目PEROJECTTARGETS的** Excluded Architectures**中

  • 路径1: PEROJECT - Build Settings - Excluded Architectures

  • 路径2: TARGETS - Build Settings - Excluded Architectures

路径1 路径2
  • 在Podfile中添加下面配置
post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
end
  • clearn项目, 终端执行pod install, 重新运行项目

解决方案二 Rosetta (推荐)



解决M1机型无法编译模拟器的关键是 针对模拟器的包要同时包含arm64和x86_64指令集。

项目中只要有一个框架没有支持模拟器的arm64指令,在M1机器上,模拟器只能以Rosetta模式运行应用,或者别的方案支持.

相关文章

网友评论

      本文标题:M1芯片simulate运行arm64与x86_64问题

      本文链接:https://www.haomeiwen.com/subject/hxbnzrtx.html