ChatGPT解决这个技术问题 Extra ChatGPT

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?

stackoverflow.com/questions/60227353/… Can any one help me in these errors

S
Silicum Silium

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.

https://i.stack.imgur.com/M6w7Q.png


@JacobSiegel can you provide more info about your Locations tab in XCode, please.
@leo7r Thank you. My CL Tools were blank. I changed the setting to Xcode 8.0 and that resolved the issue. You might want to highlight that out in your answer. Cheers!
Command Line Tools dropdown select was blank for me, Only option I had when clicking was Xcode 9.2, which I selected, saved changes and instruments was available to react-native. thanks!
So I had done that and for some reason installing homebrew disabled it. I had to select it again from xcode after installing homebrew.
Still have the error even with a CLT selected... :/
o
odlp

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

https://i.stack.imgur.com/cVeTY.png


Works like a charm! <3
A
Alireza

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:

https://i.stack.imgur.com/VdBJn.jpg

Press i to open iOS emulator...

https://i.stack.imgur.com/2fNj7.png

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

https://i.stack.imgur.com/3G0KO.png


The best answer, best of the bests.
still got this problem with xcode 13
u
user2066349

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.


For me, upgrading to react-native 0.64.0 was enough (from 0.63.2)
is there any workaround without upgrading react-native?
H
Heisenberg

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


Can you please explain the reason for downvote? This was a genuine answer. I was getting the exact same error.
the react native official website clearly states that you need Xcode in order for react native to work.
I was following a tutorial for beginners which assumed xcode is already installed and doesn't mention it. This error does not say that you don't have xcode installed. So, I would have never known.
M
Mario Tacke

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

You can also accept the license immediately, if you want to: sudo xcodebuild -license accept (source: apple.stackexchange.com/a/213151/89456)
L
Lovekush Vishwakarma

https://i.stack.imgur.com/fvWo9.png


Z
Zachary Melancon

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.


B
Bin

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.


p
pythonjsgeo

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

u
user11279823

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

Quit the simulator & Xcode. Opened Activity monitor, selected cpu option and search for sim, killing all the process shown as result. 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.


Z
Zorayr

Go to Xcode Preferences Locate the location tab Set the Xcode version in Given Command Line Tools

Now, it ll successfully work.


D
Dániel Gergely

If the previous answers didn't help you, you're probably dealing with an outdated react-native version. If you want to run your app on device without upgrading React-Native, you'll have to run the app directly from Xcode instead of doing it in the CLI. So open the <appname>.xcworkspace, select your device on the right-hand dropdown and press the "Run" icon.

Xcode screenshot


U
Unnikrishnan

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


C
CruzNadin

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.


k
khokanuzzaman khokan

simply go to Xcode

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


C
CKE

For any such problem:

Go to .expo folder Find apk-cache Remove that folder

and you are done..

Hope it helps?