Command PhaseScriptExecution failed with a nonzero exit code Xcode 11.3.1

Viewed 11353

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
5 Answers

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

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

Try the following steps:

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

See this image for reference:

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

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.

Related