升级Xcode 14.3后React Native无法在iOS模拟器运行求助
Xcode 14.3 升级后 React Native iOS 模拟器运行报错解决方案
问题说明
升级Xcode 14.3后,React Native项目可正常完成archive构建,但iOS模拟器启动时报错:
Building for iOS Simulator, but linking in object file built for iOS, file '/ios/Pods/GooglePlaces/Frameworks/GooglePlaces.framework/GooglePlaces' for architecture arm64
本质是模拟器构建时引入了仅支持iOS真机的arm64架构框架,导致架构不匹配。
解决方法
方法1:修改Podfile配置
在项目的ios/Podfile中添加针对GooglePlaces的架构排除规则,确保模拟器构建时跳过arm64:
post_install do |installer| installer.pods_project.targets.each do |target| # 为GooglePlaces设置模拟器排除arm64 if target.name == 'GooglePlaces' target.build_configurations.each do |config| config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' end end # 保留原有React Native的post_install配置 react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end
修改后执行命令重新安装依赖:
cd ios && pod install && cd ..
方法2:手动修改Xcode项目架构设置
- 打开ios目录下的
.xcworkspace文件 - 选中项目主Target,进入
Build Settings,搜索Excluded Architectures - 在
Debug - Any iOS Simulator SDK中添加arm64 - 同样找到Pods项目下的
GooglePlacesTarget,重复上述步骤,确保模拟器架构排除arm64 - 清理项目(
Cmd+Shift+K)后重新构建
方法3:关闭Xcode的Rosetta模式(仅M系列芯片Mac)
- 右键应用程序中的Xcode图标,选择「显示简介」
- 取消勾选「使用Rosetta打开」
- 重启Xcode后重新构建项目
内容的提问来源于stack exchange,提问作者DotsquareReactNative
相关产品推荐
相关产品推荐

