expo eject - can't build iOS with latest version


Hell! I’ve been stuck for a few days on this with my app, so I set out to create an expo app from scratch and ran into the same issue…

  1. expo init (npm install, etc)
  2. expo eject (npm install, etc)
  3. cd ios (pod install, etc)
  4. open workspace in xcode, run/deploy to simulator --> error
// build phase
PhaseScriptExecution Prepare\ Expo /Users/<my_user>/Library/Developer/Xcode/DerivedData/<app-name>-eydycrrjqvoslgbhexyurtyncsyc/Build/Intermediates.noindex/<app-name>.build/Debug-iphonesimulator/<app-name>.build/Script-B5722AD01DFB7E3F0084848F.sh

// script that fails
/bin/sh -c /Users/<my_user>/Library/Developer/Xcode/DerivedData/<app-name>-eydycrrjqvoslgbhexyurtyncsyc/Build/Intermediates.noindex/<app-name>.build/Debug-iphonesimulator/<app-name>.build/Script-B5722AD01DFB7E3F0084848F.sh

// results
Please install expo-cli command
Command /bin/sh failed with exit code 1
expo --version

Android builds as expected from the command-line.


Well, good news and bad. The script calls ‘expo’ to make sure it is there. The bad news is that $PATH gets overwritten at some point. I use nvm, which means global node modules aren’t in the usual location

which expo

Here is what $PATH looks like during the iOS build process

   export PATH=/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/usr/bin:/Users/chris/Downloads/Xcode-beta.app/Contents/Developer/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I’d appreciate input on how to fix it:

  1. Dump nvm, which I assume will get expo into /usr/bin ?
  2. Hack the build script (there are at least 2 places where it looks for ‘expo’ that I’ve found
  3. Other? It seems like this is a bug, though I couldn’t find where this takes place in the source code.

Any insights would be appreciated.


After a bit more digging, it seems NVM causes similar issues in other cases with xcode:

And this is why Docker has displaced local builds :frowning:

After thinking about it for the weekend, I think that my best bet is to ditch NVM, since other scripts (including detach/signing/etc) could actually be failing silently for the same reason and I may be fighting this in other areas.

Any other thoughts would be appreciated.


I think I have the same problem, with exactly the same error message. I didn’t use NVM though. All I did is calling expo eject and I select ExpoKit.


It would be great to get a response from Expo on this. Having the exact same issue. Being told to install expo-cli, even though it is installed and running ‘expo’ commands in the cli works normally.


Here is how I tracked it down. After ejection:

  1. open the ios workspace file in xcode
  2. go to project navigator --> Build phases --> Prepare Expo
  3. Insert whatever debug code you need to here. I think i tried just running ‘expo’, then hacking the PATH, etc.
  4. In the error, it outputs everything that happens in this script.

Be warned: There is a similar script in “Bundle expo assets” phase that only gets run in prod mode.


Hi, sorry for this inconvenience :disappointed: We’re looking into this and will reach out to you once we find universal solution and fix it.
For now, I can confirm that what @cdelcol wrote above is correct and should be enough to workaround this problem.


Could you provide a code snippet? I’m still struggling to get this to work. I tried hard coding the PATH so that it leads to expo, and running it in command line works just fine, but still fails in Xcode.

Here’s a snippet of what I have:

PATH="/Users/jordanestes/.nvm/versions/node/v8.9.1/bin/expo" $expo prepare-detached-build --platform ios

Do you see anything wrong?


We’ve just released a new version of ExpoKit (v2.8.4) which solves this issue. Unfortunately, you might need to do expo eject again or just apply below changes to your Xcode project configuration in “Build Phases” tab.

Correct script for “Prepare Expo” phase:

set -eo pipefail

pushd "${SRCROOT}/.."
value="$(cat ~/.expo/PATH)"
PATH="$PATH:$value" expo prepare-detached-build --platform ios

and for “Bundle Expo Assets” phase:

set -eo pipefail

if [ "$CONFIGURATION" == "Debug" ]; then
  echo "Skipping asset bundling in debug mode."
  exit 0

pushd "${SRCROOT}/.."
value="$(cat ~/.expo/PATH)"
PATH="$PATH:$value" expo bundle-assets --platform ios --dest "$dest"

Command PhaseScriptExecution failed with a nonzero exit code

:smile: I did this:

 nvm deactivate // remove the nvm path
brew install node //install node at a global location
yarn global install expo-cli //now installs somewhere in a normal non-nvm path

That is it. When I re-open the terminal nvm is back, but the global node with expo-cli just sit there unused except for by xcode. I just have to remember to upgrade it in the extra location.


Yeah, it was also a good workaround for this issue but with the scripts I posted above (or in newly ejected app that already contains them) you don’t need to remember to upgrade global (non-nvm) expo-cli :wink: So I recommend this solution anyway :slightly_smiling_face:


I just rebuilt my project from expo init and expo eject and am still receiving the same error. I am getting this error when trying to archive.

Command PhaseScriptExecution failed with a nonzero exit code

Do you have any suggestions what I can try or what information I can provide to try to resolve this?


Hey @scasarotto,

Could you check if the scripts that you have in Xcode project settings -> Build Phases are the same that I posted above?


Yeah they are:

Prepare Expo:

set -eo pipefail

pushd "${SRCROOT}/.."
value="$(cat ~/.expo/PATH)"
PATH="$PATH:$value" expo prepare-detached-build --platform ios

Build Expo Assets:

set -eo pipefail

if [ "$CONFIGURATION" == "Debug" ]; then
  echo "Skipping asset bundling in debug mode."
  exit 0

pushd "${SRCROOT}/.."
value="$(cat ~/.expo/PATH)"
PATH="$PATH:$value" expo bundle-assets --platform ios --dest "$dest"

Also, I tried not rebuilding from expo init but just adding these scripts and that didn’t fix it either for me when archiving.


So, if I understand correctly, you can build it, but you can’t archive it? That’s weird :thinking: Could you try to expand Xcode logs to get more details on what failed in the script?


Yeah I can build and run on simulator just fine. (Was able to even before running into this error when archiving.)

Xcode Error Output. Let me know if more would be helpful.

~/Documents/38thStreetStudios/Work/FirstClassDispatch/fc-chauffeur ~/Documents/38thStreetStudios/Work/FirstClassDispatch/fc-chauffeur/ios
[12:59:29] Error reading the manifest file. Make sure the path '/Users/stuartcasarotto/Documents/38thStreetStudios/Work/FirstClassDispatch/fc-chauffeur/ios/fc-chauffeur/Supporting/shell-app-manifest.json' is correct.

Error: Unexpected end of JSON input
[12:59:29] Set EXPO_DEBUG=true in your env to view the stack trace.
Command PhaseScriptExecution failed with a nonzero exit code

When I look into that file I see a blank file. Is it expected to be an empty file?

EDIT: Maybe my issue is separate from this. Happy to start a different thread.
EDIT 2: Can recreate this with the following steps:

  1. expo init
  2. yarn install
  3. Add ios/bundleIdentifier and android/package to app.json
  4. expo eject
  5. cd ios
  6. pod install
  7. Open in xcode and attempt to archive


It looks like you need to run expo publish before you try to archive. It should generate shell app manifest which is then bundled in the app.
Let me know if that helped! :wink:


Ah really sorry about this. All the threads mentioning Command PhaseScriptExecution failed with a nonzero exit code pointed back here.

Really appreciate your help.


Was having the exact same issue. Unable to archive. I’ve been having problems with OTA updates not sending assets correctly, so wanted to avoid publishing, but as long as I have “enabled” set to false for OTA, it shouldn’t matter, right?


Hey @estesjl,
Yeah, it shouldn’t matter. You need to run publish to generate a manifest and JS bundle so they can be included in your native build :wink:

Can you also describe your problems with OTA? Have you already created a thread for this?