Error Running React Native App From Terminal (iOS)

Error Running React Native App From Terminal (iOS)

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?

Solutions/Answers:

Solution 1:

Check out this link: https://github.com/facebook/react-native/issues/7965. 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:

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:

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:

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 5:

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

Solution 6:

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