执行npx react-native run-ios遇Xcode构建错误(错误码65)求解决方案
React Native iOS项目启动失败(error code 65)解决办法
执行
npx react-native run-ios启动React Native iOS项目时失败,报错信息如下:error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening test.xcworkspace. Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace test.xcworkspace -configuration Debug -scheme test -destination id=8E4F9416-0C08-4ACA-B41D-D950C2208A66 User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES Prepare packages ........ Computing target dependency graph and provisioning inputs The following build commands failed: PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/mohammedsuja/Library/Developer/Xcode/DerivedData/test-eabnxomykigrnaepxsyqxilqoeiw/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-rncore.build/Script-46EB2E00018190.sh (in target 'React-rncore' from project 'Pods') (1 failure)
解决步骤
清理Pod依赖与缓存
- 进入项目ios目录:
cd ios - 删除Pod锁文件和Pods文件夹:
rm -rf Podfile.lock Pods - 清除Xcode派生数据:
rm -rf ~/Library/Developer/Xcode/DerivedData - 重新安装Pods:
pod install
- 进入项目ios目录:
检查Xcode配置
- 打开项目的
test.xcworkspace(不要打开.xcodeproj文件) - 确认项目Bundle Identifier正确,在Signing & Capabilities面板选择匹配的开发团队
- 修复脚本权限:找到Pods项目下的React-rncore目标,进入Build Phases面板,定位
[CP-User] Generate Specs脚本,在终端执行chmod +x /Users/mohammedsuja/Library/Developer/Xcode/DerivedData/test-eabnxomykigrnaepxsyqxilqoeiw/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-rncore.build/Script-46EB2E00018190.sh赋予可执行权限
- 打开项目的
适配依赖版本
- 若使用的React Native版本较旧,升级到稳定版:
npx react-native upgrade - 核对package.json与Podfile中的依赖版本,确保二者适配当前React Native版本
- 若使用的React Native版本较旧,升级到稳定版:
重新构建项目
- 在Xcode中执行Clean Build Folder(快捷键Cmd+Shift+K)
- 选择对应模拟器,点击Build按钮尝试构建
- Xcode构建成功后,回到终端执行
npx react-native run-ios
内容的提问来源于stack exchange,提问作者Mohamed suja
相关产品推荐
相关产品推荐

