OhStack
OhStack

Reputation: 116

Command PhaseScriptExecution failed with a nonzero exit code Xcode 11.3.1

I am getting Command PhaseScriptExecution failed with a nonzero exit code error frequently, The below workarounds which I followed but didn't help me.

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

Workaround2: Build Phases -> Targets -> Embedded pods frameworks "Run script only while installing"

Workaround3: Deleting the derived data

Workaround2: Clean project and building again.

Find the below log

Library/Developer/Xcode/DerivedData/CompanyName-
bofekdusvsoagmhinknpcoyjfyoj/Build/Intermediates.noindex/CompanyName.build/Debug-
iphonesimulator/company-iOS.build/Script-2AD2DCB21F0D6514005CEF4D.sh: line 2: 20846 
Segmentationfault: 11  ../BuildSupport/swift_lint_check.sh

Upvotes: 6

Views: 16901

Answers (7)

0ozen
0ozen

Reputation: 59

It might happen because of a few reasons, as the different answers suggest. If none of those worked, check if the ports used by Metro (like 8081) are busy. Restarting your computer might also be a good start. Then clean the build folder (Product -> Clean Build Folder) and build again.

In my case I was running on my laptop a server which used the port 8081, that's when I got the error as I was launching my Xcode app.

Upvotes: 0

dhika aditya
dhika aditya

Reputation: 11

4 days I tried to find a solution regarding "Command PhaseScriptExecution failed with a nonzero exit code" on M1, and in the end, I found the solution.

Save your time by following these steps:

  1. Close your Xcode (command + Q)
  2. Open finder and select the application folder,
  3. In the application folder, look for the Xcode application,
  4. If you find the Xcode application, right-click on it and make sure you tick or check "open using Rosetta"
  5. Open your project again and then ....(ta daaa).

But in my case, I had to delete my project and re-clone it from the Github repository before opening the project.

Let me know if this method works wkkwkw.

see how it works

Upvotes: 1

mgm
mgm

Reputation: 1288

If this issue is caused by Firebase Crashlytics try removing all spaces from the project path.

I faced the same issue and tried all solutions and workarounds and nothing worked.

With Workaround2: Build Phases -> Targets -> Embedded pods frameworks "Run script only while installing" I only managed to build the project but not to archive it in order to upload to the app store. This made me sure that the issue was with one of the pods embedded there.

After a bit of trial and error, I discovered that the Firebase Crashlytics framework was the cause of the problem because the folder in which I had the Xcode project had two words with a space between. All I had to do was to move the project into a new folder that had no space anywhere in its path

Upvotes: 0

Anees
Anees

Reputation: 522

It was funny, it was due to wifi switched off in my case. When i switched on the wifi and run again the build got succeed.

Upvotes: -1

Naresh
Naresh

Reputation: 17902

I have faced the same issue in Xcode 13. I have updated the Crashlytics SDK after that I got the same issue. In my case I have followed the Solution2

Solution1:

I have removed the data from Run Script.

-> Targets ->go to Build Settings ->Click Run Script -> Remove data

enter image description here

Solution2:

If script is mandatory to your project just select install builds only option.

Select Check box For install builds only option

enter image description here

Upvotes: 3

Suo
Suo

Reputation: 11

Try the following steps:

  • Targets → Build Settings → Valid Architectures.
  • Add "arm64".

See this image for reference:

Upvotes: 1

rubik
rubik

Reputation: 602

This may happen when you click "Deny" on Keychain access dialog, after this, you can make Workaround1 and then try to restart your Mac. Also not forget to use the latest version of swiftlint and pods, make pod update SwiftLint. After the restart, you can try to make:

$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean

Upvotes: 2

Related Questions