Error Running React Native App From Terminal (iOS)

JavascriptIosReactjsReact NativeIos Simulator

Javascript Problem Overview


I am following the tutorial on the official React Native website.

Using the following to build my project:

react-native run-ios

I get the error:

Found Xcode project TestProject.xcodeproj
xcrun: error: unable to find utility "instruments", not a developer   
tool or in PATH

Command failed: xcrun instruments -s
xcrun: error: unable to find utility "instruments", not a developer 
tool or in PATH

Although, when I run the app from the .xcodeproj, everything works fine.

Any suggestions?

Javascript Solutions


Solution 1 - Javascript

Check out this link (Running react-native run-ios occurs an error?). It appears to be a problem with the location of Command line tools.

In Xcode, select Xcode menu, then Preferences, then Locations tab. Select your Xcode version from the dropdown and exit Xcode.

XCode location tab

Solution 2 - Javascript

You may need to install or set the location of the Xcode Command Line Tools.

Via command line

If you have Xcode downloaded you can run the following to set the path:

sudo xcode-select -s /Applications/Xcode.app

If the command line tools haven't been installed yet, you may need to run this first:

xcode-select --install

You may need to accept the Xcode license before installing command line tools:

sudo xcodebuild -license accept 

Via Xcode

Or adjust the Command Line Tools setting via Xcode (Xcode > Preferences > Locations):

Xcode preferences - Locations tab

Solution 3 - Javascript

By default, after installing Xcode command-line not selected, so open Xcode and go to Preferences >> Locations and set Command Line Tools...

This worked for me in MAC High Sierra, Xcode Version 9.3:

Xcode Preferences

Press i to open iOS emulator...

Press a to open Android device or emulator, or i to open iOS emulator.

And You can see a cool new iPhone simulator like below image:

React Native prints, I'm Alireza Dezfoolian, a Front End Developer!

Solution 4 - Javascript

In my case the problem was that Xcode was not installed.

Solution 5 - Javascript

An update for anybody (like me) who's run into this in Xcode 13 -- the instruments command has been removed.

Updating to the latest version of react-native in your package.json file will no longer try to use the instruments command.

Solution 6 - Javascript

I had to accept the XCode license after my first install before I could run it. You can run the following to get the license prompt via command line. You have to type agree and confirm as well.

sudo xcodebuild -license

Solution 7 - Javascript

Problem is your Xcode version is not set on Command Line Tools, to solve this problem open Xcode>Menu>preferences> location> here for Command Line tools select your Xcode version, that's it. enter image description here

Solution 8 - Javascript

For those like me who come to this page with this problem after updating Xcode but don't have an issue with the location setting, restarting my computer did the trick.

Solution 9 - Javascript

For me, it turns out that there was an iOS system update pending asking to restart the computer. Restart and let the update finish solved my problem.

Solution 10 - Javascript

In my case the SDKROOT environment variable was wrong, which referred to an old version of iPhoneOSxx.x.sdk. (Perhaps this would have automatically resolved itself after a reboot?)

You can check by running echo $SDKROOT and verifying that it's a valid path.

I fixed it by updating in .bash_profile:

export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk

Solution 11 - Javascript

None of these solutions worked for me. These two similar problems offer temporary solutions that worked, it seems the simulator process isn't being shutdown correctly:

Killing Simulator Processes

From https://stackoverflow.com/a/52533391/11279823

  1. Quit the simulator & Xcode.
  2. Opened Activity monitor, selected cpu option and search for sim, killing all the process shown as result.
  3. Then fired up the terminal and run sudo xcrun simctl erase all. It will delete all content of all simulators. By content if you logged in somewhere password will be gone, all developer apps installed in that simulator will be gone.

Opening Simulator before starting the package

From https://stackoverflow.com/a/55374768/11279823

open -a Simulator; npm start

Hopefully a permanent solution is found.

Solution 12 - Javascript

  1. Go to Xcode Preferences

  2. Locate the location tab

  3. Set the Xcode version in Given Command Line Tools

Now, it ll successfully work.

Solution 13 - Javascript

In Mac: After all, you are getting this issue, there may be a chance of missing the following in System Preferences -> Network -> Ethernet -> Select Advanced -> Proxies

add the following line,

*.local,localhost

Solution 14 - Javascript

This is how I got the solution,

> rm -rf ~/Library/Developer/Xcode/DerivedData
> sudo rm -rf /Library/Developer/CommandLineTools
> xcode-select --install
> sudo xcodebuild -license accept

Xcode > Preferences > Location > Command Line Tools choose.

Solution 15 - Javascript

simply go to Xcode

click on Xcode from the top left menu Xcode->preferences-> location-> click comman line option and set Xcode version.

Solution 16 - Javascript

For any such problem:

  1. Go to .expo folder
  2. Find apk-cache
  3. Remove that folder

and you are done..

Hope it helps?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJacobSiegelView Question on Stackoverflow
Solution 1 - Javascriptleo7rView Answer on Stackoverflow
Solution 2 - JavascriptodlpView Answer on Stackoverflow
Solution 3 - JavascriptAlirezaView Answer on Stackoverflow
Solution 4 - JavascriptHeisenbergView Answer on Stackoverflow
Solution 5 - Javascriptuser2066349View Answer on Stackoverflow
Solution 6 - JavascriptMario TackeView Answer on Stackoverflow
Solution 7 - JavascriptLovekush VishwakarmaView Answer on Stackoverflow
Solution 8 - JavascriptZachary MelanconView Answer on Stackoverflow
Solution 9 - JavascriptBinView Answer on Stackoverflow
Solution 10 - JavascriptpythonjsgeoView Answer on Stackoverflow
Solution 11 - Javascriptuser11279823View Answer on Stackoverflow
Solution 12 - JavascriptApurva AggarwalView Answer on Stackoverflow
Solution 13 - JavascriptUnnikrishnanView Answer on Stackoverflow
Solution 14 - JavascriptCruzNadinView Answer on Stackoverflow
Solution 15 - Javascriptkhokanuzzaman khokanView Answer on Stackoverflow
Solution 16 - JavascriptansofficiallyView Answer on Stackoverflow