Unable to Run RN 0.59 CLI's 'run-ios' on xCode 13
See original GitHub issueI am maintaining an app that still runs on react native 0.59. I recently upgraded my MacBook to Big Sur, and now I am getting issues attempting to run my react native app that is on 0.59.10. Our script in package.json to run a version of our iOS app looks like:
"ios-debug": "node node_modules/react-native/local-cli/cli.js run-ios"
I am getting the following error after upgrading to Big Sur and xCode 13:
info Found Xcode workspace {APPNAME}.xcworkspace
xcrun: error: Failed to locate 'instruments'.
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
error Command failed: xcrun instruments -s
xcrun: error: Failed to locate 'instruments'.
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
I see this tool (instruments) has been removed now. Since @react-native-community/cli is a transitive library that react-native includes itself, how do I go about using a newer version of the CLI tools? I attempted to install @react-native-community/cli-platform-ios
to see if that would get me anywhere, but I had no luck finding a replacement to the node node_modules/react-native/local-cli/cli.js run-ios
that the ios-debug
script runs.
Does anyone have any advice? We are in the middle of upgrading said app, but we would really like to continue make changes to our existing app until our updated app is ready. Any help is really appreciated, thank you!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:6
Top GitHub Comments
Short answer
Upgrade react-native to 0.64.0.
Long answer
Since Xcode 13
$ xcrun instruments
is not available any more. There is a patch to usexctrace
overinstruments
and included in @react-native-community/cli 5.0.1-alpha.1. react-native supports this cli version since v0.64.0.I just spent my all night and found a solution, that error happed because Xcode 13 removed instruments. So the solution is to avoid to run instruments. replace your runIOS function in runIOS.js file(/node_modules/react-native/local-cli/runIOS/runIOS.js )
function runIOS(argv, config, args) { if (!fs.existsSync(args.projectPath)) { const reactNativeScriptsPath = findReactNativeScripts(); if (reactNativeScriptsPath) { child_process.spawnSync( reactNativeScriptsPath, [‘ios’].concat(process.argv.slice(1)), {stdio: ‘inherit’}, ); return; } else { throw new Error( ‘iOS project folder not found. Are you sure this is a React Native project?’, ); } } process.chdir(args.projectPath); const xcodeProject = findXcodeProject(fs.readdirSync(‘.’)); if (!xcodeProject) { throw new Error(‘Could not find Xcode project files in ios folder’); }
const inferredSchemeName = path.basename( xcodeProject.name, path.extname(xcodeProject.name), ); const scheme = args.scheme || inferredSchemeName; console.log(
Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} ${ xcodeProject.name }
, );/* const devices = parseIOSDevicesList( child_process.execFileSync(‘xcrun’, [‘instruments’, ‘-s’], { encoding: ‘utf8’, }), ); if (args.device) { const selectedDevice = matchingDevice(devices, args.device); if (selectedDevice) { return runOnDevice( selectedDevice, scheme, xcodeProject, args.configuration, args.packager, args.verbose, args.port, ); } else { if (devices && devices.length > 0) { console.log( ‘Could not find device with the name: "’ + args.device + ‘".’, ); console.log(‘Choose one of the following:’); printFoundDevices(devices); } else { console.log(‘No iOS devices connected.’); } } } else if (args.udid) { return runOnDeviceByUdid(args, scheme, xcodeProject, devices); } else {*/ return runOnSimulator(xcodeProject, args, scheme); //} }then start debug with specific simulator: react-native run-ios --simulator “iPhone X”