Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Command PhaseScriptExecution failed with a nonzero exit code" when archiving

so I have an app built with Expo but then ejected to get ios and android folder everything works fine on both android and ios I have published it for android but on ios when I try to archive the project it gives me an error Command PhaseScriptExecution failed with nonzero exit code i don't know what's causing this error I have read a lot of StackOverflow questions tried a lot of things but with no luck here's what I tried so far.

I tried:

  • removing pod lock file, removing pod folder, doing pod deintegrate, doing pod update
    • locking and unlocking the login in keychainAccess
    • cleaning build folder in xcode
    • restarting my laptop and xcode
    • changing to legacy build system from new build system
    • removing DerivedData folder and cleaning Xcode
  • upgrading cocopods and doing pod install again

Okay so before, building with Command+B also didn't work but now i went to Targets->App name->build phases->bundle expo assets-> and checked the " run script only while installing" option and building started working but archiving still doesn't work

along with the above error i also noticed another error on xcode

enter image description here

So please if anyone has any ideas why this is happening, please?

error screenshot

like image 364
Surafel Avatar asked Jun 07 '20 12:06

Surafel


4 Answers

One possible reason could be that Xcode is using an outdated version of Node (in my case, it was because I use nvm to manage my Node versions, but Xcode used an old version of Node that I had installed via HomeBrew a long time ago).

By default, Xcode will use the Node binary located at /usr/local/bin/node. Check its version by running:

/usr/local/bin/node -v
node -v

If the first command outputs an older version of Node, simply delete it and replace it with a symlink to the newer one:

rm -rf /usr/local/bin/node
ln -s $(which node) /usr/local/bin/node
like image 182
glocore Avatar answered Sep 23 '22 16:09

glocore


If you are using nvm, unsetting the default alias fixes the issue.

$ nvm unalias default

or if it asking to set nvm default:

$ nvm alias default node

Build the app again.

like image 43
Kumar Parth Avatar answered Sep 23 '22 16:09

Kumar Parth


Solution 1:

it is due to Bare Expo Bundle Assets

here is the actual issue raised on forum: https://forums.expo.io/t/ios-bundle-assets-error-when-building-release-403/36616

this pull (fix) request has merged into master

-

Solution:

update your expo-cli to [email protected] or higher

npm install -g expo-cli

-

Note: Solution 1 is the answer to this question

Solution 2:

Open project directory on the terminal and run this command and archive again

react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ./ios/main.jsbundle

Solution 3:

Go to

Keychain Access -> Right-click on login -> Lock & unlock again -> Clean Xcode project ->Make build again

like image 35
Muhammad Numan Avatar answered Sep 20 '22 16:09

Muhammad Numan


This issue for me was that I had the project in a directory with spaces in the name. An intermediate script that FBReactNativeSpec builds is referencing paths without escaping spaces, so it failed.

like image 43
John Scalo Avatar answered Sep 21 '22 16:09

John Scalo