You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native或Xcode报错:无法找到工具“instruments”,非开发工具或不在PATH中

M1芯片Monterey Beta系统xcrun找不到instruments报错解决方案

完整报错内容如下:

xcrun: error: sh -c '/Applications/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find instruments 2> /dev/null' failed with exit code 17664: (null) (errno=No such file or directory)
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH

报错根本原因

Xcode 13及更高版本的Beta配套Monterey系统使用时,官方已经彻底移除了原有的instruments命令行工具,替换为全新的xctrace命令。低于0.66版本的React Native内置构建脚本仍然在调用已被删除的instruments工具,因此会触发该报错。

可执行解决方案

  • 方案一:升级React Native到0.66及以上正式版本,该版本已经完成Xcode 13+适配,官方替换了所有对废弃instruments命令的调用
  • 方案二:如果项目暂时无法升级RN版本,手动修改本地RN依赖的构建脚本即可:
    打开路径为node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js的文件,将文件中所有调用instruments的逻辑,替换为调用xcrun xctrace list devices获取模拟器列表
  • 方案三:若调整后仍报错,先确认Xcode命令行工具路径配置正确,执行以下命令指定当前使用的Xcode Beta的开发者路径:
    sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
    
    执行完成后重启终端,重新运行构建命令即可生效

内容的提问来源于stack exchange,提问作者Nick H

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 23:27:00