React Native升级遇Pods缓存异常及xcrun simctl错误求助
解决React Native 68.5升级中的xcrun simctl及依赖编译问题
一、解决xcrun simctl找不到工具的问题
- 检查Xcode命令行工具路径:
执行xcode-select --print-path,若输出不是/Applications/Xcode.app/Contents/Developer,运行sudo xcode-select -s /Applications/Xcode.app/Contents/Developer重置路径。 - 确认Xcode命令行工具配置:
打开Xcode,进入偏好设置→Locations→Command Line Tools,手动选择当前安装的Xcode版本。 - 修复Xcode工具链:
执行xcodebuild -runFirstLaunch初始化Xcode命令行工具,修复可能损坏的工具链关联。 - 验证Xcode版本:
React Native 68.5要求Xcode 13.2及以上版本,若版本过低需升级到对应版本。
二、解决依赖安装与编译错误问题
1. 彻底清理项目缓存
- 删除
node_modules文件夹、package-lock.json/yarn.lock,重新执行npm install或yarn install。 - 执行
pod deintegrate移除Pod依赖,删除Podfile.lock和Pods文件夹后,重新运行pod install。 - 清空模拟器缓存:执行
xcrun simctl erase all,或在Xcode→Window→Devices and Simulators中选中模拟器,右键选择"Erase All Content and Settings"。
2. 统一iPhone Deployment Target配置
- 打开
Podfile,顶部设置platform :ios, '12.4'(RN68.5最低要求iOS 12.4)。 - 在Xcode项目Build Settings→Deployment→iOS Deployment Target中设置为12.4或更高,同时在
Podfile添加钩子自动同步Pods的配置:post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4' end end end - 执行
pod install让配置生效。
3. 匹配Expo SDK与React Native版本
- RN68对应Expo SDK 45,在
package.json中锁定相关包版本:"expo": "~45.0.0", "expo-modules-core": "~0.12.0" - 运行
npx expo-cli doctor检测依赖不匹配问题,按提示修复。
4. 解决CompileC指向DerivedData的问题
- 在Xcode中执行Product→Clean Build Folder(快捷键
Cmd+Shift+K),再重新编译。 - 检查DerivedData路径权限:在Xcode→Preferences→Locations→DerivedData中查看路径,手动删除该文件夹后重启Xcode。
内容的提问来源于stack exchange,提问作者Before The Empire
相关产品推荐
相关产品推荐

