React Native 0.65与XCode 14.3不兼容:运行run-ios命令报错求助
React Native编译Yoga模块失败的解决方法
可行的排查与修复步骤
核对Xcode与React Native版本兼容性
React Native不同版本对Xcode有明确版本要求(例如RN 0.70+需Xcode 13.4及以上)。打开Xcode查看版本(Xcode → 关于Xcode),若版本不匹配,升级到对应兼容版本。指定目标架构编译
打开ios目录下的{projectname}.xcworkspace,找到Pods项目中的Yoga target:- 选中Yoga target,进入「Build Settings」
- 找到「Architectures」,根据你的芯片类型设置为
arm64(M系列)或x86_64(Intel);同时将「Build Active Architecture Only」在Debug模式下设为YES
手动清理Xcode派生数据
执行命令删除Xcode的Derived Data:rm -rf ~/Library/Developer/Xcode/DerivedData之后重新运行
pod install和react-native run-ios --simulator="iPad Pro (12.9-inch) (6th generation)"调整Yoga的编译参数
在项目根目录的Podfile末尾添加以下配置,强制指定C++标准:post_install do |installer| installer.pods_project.targets.each do |target| if target.name == 'Yoga' target.build_configurations.each do |config| config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' end end end end保存后重新执行
pod install重新初始化项目(终极手段)
若上述方法均无效,备份当前项目文件后,重新克隆代码仓库,从头执行npm install、cd ios && pod install,再尝试运行项目,排除本地文件损坏或缓存残留问题。
内容的提问来源于stack exchange,提问作者maks1mp
相关产品推荐
相关产品推荐

