iOS M1芯片Mac上Xcode模拟器报错解决

真机编译可以通过,模拟器失败,出现以下错误

..., building for iOS Simulator, but linking in object file built for iOS, file '...'

或者

could not find module for target 'x86_64-apple-ios-simulator'
解决方案一

1.添加arm64到项目PEROJECTTARGETSExcluded Architectures
路径1:PEROJECT - Build Settings - Excluded Architectures
路径2:TARGETS - Build Settings - Excluded Architectures

截屏2023-06-30 15.24.18.jpg
2.在项目的podfile的最后添加以下代码
post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end
3.clean项目,最后终端pod install下,重新运行项目就能在模拟器运行了

注意:之后如需在真机上运行则需把上面第一步第二步的设置恢复原状,然后pod install一下。(在上架App Store前也需这样做)

你可能感兴趣的:(iOS M1芯片Mac上Xcode模拟器报错解决)