[ios] Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code

Showing Recent Messages:-1: mkdir -p /Users/spritzindia/Library/Developer/Xcode/DerivedData/Contigo-atftiouzrdopcmcpprphpilawwzm/Build/Products/Debug-iphonesimulator/Contigo.app/Frameworks

Showing Recent Messages:-1: rsync --delete -av --filter P .*.?????? --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/pothi/Library/Developer/Xcode/DerivedData/Contigo-atftiouzrdopcmcpprphpilawwzm/Build/Products/Debug-iphonesimulator/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework" "/Users/pothi/Library/Developer/Xcode/DerivedData/Contigo-atftiouzrdopcmcpprphpilawwzm/Build/Products/Debug-iphonesimulator/Contigo.app/Frameworks"

Command PhaseScriptExecution failed with a nonzero exit code

I deleted derived data. i have tried :

keychain access -> right click on login -> lock & unlock again -> clear Xcode project

Restarted machine, no use

How do I resolve "Command PhaseScriptExecution failed with a nonzero exit code" error when trying to archive project.

And I am using those librarys

pod 'IQKeyboardManagerSwift'
pod 'SDWebImage', '~> 4.0'
pod 'KRPullLoader'
pod 'Paytm-Payments'

This question is related to ios swift xcode cocoapods xcode10.2.1

The answer is


Go to

  1. Keychain Access -> Right-click on login -> Lock & unlock again

  2. Xcode -> Clean Xcode project ->Make build again


After trying all the solutions, I was missing is to enable this option in:

Targets -> Build Phases -> Embedded pods frameworks

In newer versions it may be listed as:

Targets -> Build Phases -> Bundle React Native code and images

  • Run script only when installing

Build Phases


For me, the issue was with the node version that xcode was using. My project was building fine in Expo but not in Xcode after ejecting. I found my answer here: https://github.com/expo/expo/issues/8488

  • check you have the latest version of node

    $ node --version

  • delete the version in /usr/local/bin/

    $ rm /usr/local/bin/node

  • re add a sym link

    $ ln -s $(which node) /usr/local/bin/node


Take Pods-resources.sh from project path and paste in Terminal

sudo chmod a+x "Pods-resources.sh file path here"

Example Usage:

sudo chmod a+x "/Users/path/Desktop-path/My Work-path/Pods/Pods-resources.sh"

For me, I was removing Crashlytics, Fabric and FirebaseCrashlytics. So there was a script (Run Script) for Fabric. So since app was running that first and I had removed the framework already, I was getting this error. So I removed the Run Script tab for Fabrics and then it worked perfectly fine.


In my case the error was caused by the lack of space on my machine. Deleting old builds fixed the problem.


Remove a space in fileName

ex)

  • AS-IS: /Users/user/Desktop/My Projects/TestProject/
  • TO-BE: /Users/user/Desktop/MyProjects/TestProject/

I used flutter to create iOS project. When build for Simulator, failed with the same error message. It is solved by following work.

xCode 12.3 Build Settings->Build Active Architecture Only, set it to Yes.


From Xcode 12.2, you need to remove the $(VALID_ARCHS) build setting from your main and CocoaPods targets, and use $(ARCHS_STANDARD) for all targets. Also, switching to the Legacy Build System is no longer a good solution, since Xcode will deprecate this in a future release. Clear derived data after applying these changes, and before a new rebuild.


For me, the issue was with Sentry.

  1. in Xcode navigate to targets->Build Phases
  2. delete the Upload Debug Symbols to Sentry phase
  3. clean the build folder and try the build again

By mistake I had uninstalled carthage from my system. Adding that fixed the issue for me.

Step 1: Download & install latest carthage DMG here: Carthage

Step 2:

carthage update --platform iOS --cache-builds

Step 3: Run project & enjoy. :)


In my case was that I changed a line in a script of my Xcode project and that line was badly written (I forgot to add ";" at the end of the line). So I added the ";" and clean and build project.


I tried everything above nothing worked for me it was a space in a folder name

/swift files/project a/code.xcworkspace -> /swift_files/project_a/code.xcworkspace
did the trick If I looked deeper it was stopping at /swift


In my case I have removed Run Script from the Build Phase in XCode.


I tried most of above. I was developing in Flutter so what worked for me was pub cache repair.


I got the error while using react-native-config.
Got this error since I had an empty line in .env files...

FIRST_PARAM=SOMETHING

SECOND_PARAM_AFTER_EMPTY_LINE=SOMETHING

3 hours wasted, maybe will save someone time


Try this!

Build phases > Add > New Run Script Phase

Code:

# Type a script or drag a script file from your workspace to insert its path.
# skip if we run in debug
if [ "$CONFIGURATION" == "Debug" ]; then
echo "Skip frameworks cleaning in debug version"
exit 0
fi

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

Xcode will refuse to sign them. The above script removes unused architectures.


If you are doing Unity Project. You can get this error.

Command PhaseScriptExecution failed with a nonzero exit code

The solution is very simple

https://forum.unity.com/threads/error-on-build.561706/

Pre-requisites: Have cocoapods installed

Not Needed: 1. Install "cocoapods" for installing run following line in your terminal: $sudo gem install cocoapods

  1. Open your project folder using terminal
  2. Run this line: chmod +x MapFileParser.sh
  3. Run this line: chmod +x process_symbols.sh

It worked for me)

I think that installing "cocoapods" is not necessary, only step 3 and 4 enough to solve, but it does not work, you can try it.


I was able to resolve this error by remove file in Pods -> Targets Support Files -> Pods-AppName -> Pods-AppName-frameworks.sh. After removing that file again install pod using command pod install.

OR.

Try this:

-> quit xcode -> install pod(again) -> start xcode


Probably you should do as follow:

  • Remove .xcworkspace and Pod folder
  • Run pod install
  • Delete derived data
  • Clean all project (press alt before click on click)

I tried above things and it worked for me.


Try the below:

  1. pod deintegrate
  2. pod install
  3. XCode Clean build

Or, One-Liner:

pod deintegrate; pod install


Another reason for the error might be is that Xcode is running a script during the run phase.

If this is the case, you have 2 options:

  1. Delete the script (makes sense if the script is NOT important)

  2. Modify/update the scripts location path (Xcode might not be able to locate the script)

Run Phase Script

In my case, the script was important, so I modified/updated its location.

Originally, the script location path was written like this:

$SRCROOT/scripts/clean-assets.sh

Because the scripts path contained spaces (I moved the project to a new directory), I changed the path to this:

"$SRCROOT"/scripts/clean-assets.sh

By adding quotes to SRCROOT, changing it to "$SRCROOT", the error will go away.


Xcode -> File -> Workspace Setting -> change Build System to Legacy Build System.

Thats it. Have Fun


I had a similar error

/{path to project root}/Pods/Target Support Files/Pods-{project name}/Pods-{project name}-frameworks.sh: Permission denied
Command PhaseScriptExecution failed with a nonzero exit code

In my case I had received a zip of a repo that included the Pods folder. It turns out that at some point between it being originally created and sent to me, the *.sh files in Pods/Target Support Files/Pods-{PROJECT}/ had all lost their execute permissions. Giving those files +x was the solution


I had the same problem in Xcode 11.5 after revoking a certificate through Apple's developer homepage and adding it again (even though it looked different afterwards):

Every time I tried to archive my app, it would fail at the very end (not the pods but my actual app) with the same PhaseScriptExecution failed with a nonzero exit code error message. There is/was a valid team with an "Apple Development" signing certificate in "Signing & Capabilities" (project file in Xcode) and locking & unlocking the keychain, cleaning & building the project, restarting,... didn't work.

The problem was caused by having two active certificates of the same type that I must have added on accident, in addition to the renewed one. I deleted both the renewed one and the duplicate and it worked again.

You can find your certificates here or find the page like this:

Also check that there aren't any duplicates in your keychain! Be careful though - don't delete or add anything unless you know what you're doing, otherwise you might create a huge mess!


I was facing this issue because of Firebase Crashlytics. In Targets -> Build Phases -> Run Script

I had Firebase Crashlytics written like

${PODS_ROOT}/FirebaseCrashlytics/run

I changed that and put it in double quotes

"${PODS_ROOT}/FirebaseCrashlytics/run"

Restart worked for me... Mac OS restart, not xCode restart...


What helped for me was: In Targets -> Signing & Capabilities > Uncheck Automatically manage signing (or check and uncheck if it was unchecked ) > build project


Xcode 12.2 solution: Go to:

  1. Build settings -> Excluded Architectures
  2. Delete "arm64"

try this step if you need: Xcode 11.5 1- open terminal: cd Path_project 2- cd pod clean 3- pod install

if nothing change make this step

1- open Build Phases for target -> [CP] Embed Pods FrameWork check this field enter image description here


I have a project in React Native and suddenly this error appeared. I was doing something with homebrew beforehand and this solved the issue for me:

brew update
brew upgrade
brew cleanup

For Xcode 11, React Native development environment. I usually have this problem when a dependency is not updated.

You can try following these steps, this usually works for me:

1- Delete your Podfile.lock (I like to use the command '-rm -rf Podfile.lock' on the terminal for this)

2- Delete your Pods folder (I like to use the command '-rm -rf Pods' in the terminal for this)

3- Delete your .xcworkspace

4- Pod install

5- Clear your project into XCode> Product> Clean Build Folder


For me the reason was while changing name of app I added a single quote ' in name. I tried different solution and ran into different errors, but at last, while renaming app, I did not include ' single quote and it solved the problem.


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to swift

Make a VStack fill the width of the screen in SwiftUI Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code in Xcode 10 Convert Json string to Json object in Swift 4 iOS Swift - Get the Current Local Time and Date Timestamp Xcode 9 Swift Language Version (SWIFT_VERSION) How do I use Safe Area Layout programmatically? How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator Safe Area of Xcode 9 The use of Swift 3 @objc inference in Swift 4 mode is deprecated?

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to cocoapods

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Updating to latest version of CocoaPods? 'Linker command failed with exit code 1' when using Google Analytics via CocoaPods ld: framework not found Pods How to update a single pod without touching other dependencies Error "library not found for" after putting application in AdMob cocoapods - 'pod install' takes forever Xcode - ld: library not found for -lPods

Examples related to xcode10.2.1

Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code