xcrun exited with non-zero code: 4

I’m getting an error as such:

Starting Metro Bundler.
xcrun exited with non-zero code: 4
Error: xcrun exited with non-zero code: 4
    at ChildProcess.completionListener (/Users/BBE0017/Apps/spree-react-native/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
    at Object.onceWrapper (events.js:422:26)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
    ...
    at spawnAsync (/Users/BBE0017/Apps/spree-react-native/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
    at xcrunAsync (/@expo/xdl@57.9.35/src/SimControl.ts:319:18)
    at Object.bootAsync (/@expo/xdl@57.9.35/src/SimControl.ts:133:11)
    at action (/@expo/xdl@57.9.35/src/Simulator.ts:320:25)
    at waitForActionAsync (/@expo/xdl@57.9.35/src/Simulator.ts:302:22)
    at ensureSimulatorOpenAsync (/@expo/xdl@57.9.35/src/Simulator.ts:217:24)
    at Object.openProjectAsync (/@expo/xdl@57.9.35/src/Simulator.ts:651:14)
    at /Users/BBE0017/Apps/spree-react-native/node_modules/expo-cli/src/urlOpts.ts:91:11
    at async Promise.all (index 1)
    at Object.handleMobileOptsAsync (/Users/BBE0017/Apps/spree-react-native/node_modules/expo-cli/src/urlOpts.ts:76:3)
error Command failed with exit code 1.

Expo Diagnostics

Expo CLI 3.26.2 environment info:
    System:
      OS: macOS 10.15.6
      Shell: 3.2.57 - /bin/sh
    Binaries:
      Node: 12.18.3 - /usr/local/bin/node
      Yarn: 1.17.3 - /usr/local/bin/yarn
      npm: 6.14.6 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 4.0 AI-193.6911.18.40.6626763
      Xcode: 12.0/12A8189h - /usr/bin/xcodebuild
    npmPackages:
      expo: ~38.0.8 => 38.0.10 
      react: ~16.11.0 => 16.11.0 
      react-dom: ~16.11.0 => 16.11.0 
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2 
      react-native-web: ~0.11.7 => 0.11.7 
    npmGlobalPackages:
      expo-cli: 3.26.2

What can I try next ?

Hey @wevak,

Can you try updating your cli version to the latest? (3.27.12) Also, what command were you running that resulted in this error?

Cheers,
Adam

While running yarn ios the error showed up !

Hey @adamjnav,

I’ve updated the cli version to the latest, even though it doesn’t work with the Xcode Simulator, on the other hand expo-cli is perfectly working with the Android Emulator, the problem is only with the expo-cli and the Xcode Simulator.

What can I try next ?

Hello,

WHATS THE SOLUTION TO THIS PROBLEM?

Since xcrun is part of Xcode, maybe try reinstallng Xcode.

I just quit the xcode and then re opened it…
I again get the same error.

What else can i try ?
How do i check if im running the right simulator version against the right xcdoe version ?

Could this be the issue ?

I am not sure what the problem is. If you search for ways to reinstall Xcode you will see many people have weird issues with Xcode, especially after upgrading macOS.

Here’s a post that looks useful. Just make sure your machine is backed up first:

I’ve found another comment on how to reinstall the command line dev tools which seems worth a try if doing it like in the above post doesn’t work:

There’s also the following, but it seems incomplete, or could do with an explanation of what happens after the last step:

Good luck. Let us know what happens.

Same for me too