267

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'
7
  • In my case I just had to clean derived data and build again. Commented Sep 29, 2020 at 11:51
  • Could you share your Run Scripts in the Build Phases section? Commented Jan 4, 2021 at 18:50
  • Benefited me here: stackoverflow.com/questions/61116011/… I recommend you check it out. Commented Feb 17, 2021 at 5:43
  • Restarting my machine works for me every time I get this error. Commented Mar 1, 2021 at 16:17
  • 1
    Just remove space from folder name in your project path. make sure all folders are named properly. this should fix the issue Commented Sep 9, 2021 at 12:24

101 Answers 101

241

After trying all the solutions, I realized I needed to enable the following option:

Targets -> Build Phases -> Embedded pods frameworks

In newer versions, this may be listed as:

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

Ensure to check the option: Run script only when installing

Build Phases

Sign up to request clarification or add additional context in comments.

14 Comments

can anyone explain why this answer work? also will this cause any unexpected behavior I should be aware of?
Debug-installing on a device (build & run from Xcode) does not count as "installing". The run script only runs when archiving
now it's changed it's stated as run script: For install builds only
that's work in build . but error showed when i Archive project again!
If this isn't your answer, there is a recent bug in XCode 14.3 (~April 2023) that can cause this error. Simple solution here: stackoverflow.com/questions/53289524/…
|
127

Go to

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

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

14 Comments

Hi fork, anything else that you can suggest for this issue. This solution is not working for me, The link of the question I posted is - stackoverflow.com/questions/58444972/…
What is "Keychain Access"? Context please.
@AndrewKoster Keychain Access is a program in your Mac in Utilities. Cmd Tab keychain Access to find it
For me also removing Pods and podfile.lock and reinstallig pods
lock / unlock options are disabled for me. any solution?
|
121

Run the following commands from the ios directory:

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

Or, One-Liner:

pod deintegrate; pod install

9 Comments

It doesn't work for me.
i still got some issue , it doesnt work for me. mbp m1 with arch -x86_64 pod deintegrate and arch -x86_64 pod install
@YogiArifWidodo Did you try using the terminal with Rosetta? Applications -> Xcode -> GetInfo -> Open using Rosetta
no, but now i have solve by running on vscode instead of xcode , dunno why when run from xcode i got the issue, but with vscode its work normal there is no an error.
if the case proj dir contain space, this will not work. It means pod deinstall/install will not works, try like project_1
|
84

This could happen due to an issue with XCode 14.3 and cocoapods,

There are two solutions

1 - Update cocoapods as there is a recent fix: sudo gem update cocoapods reference: https://github.com/CocoaPods/CocoaPods/issues/11808

2 - The other workaround is to update all the generated ...-frameworks.sh files to add the -f flag to the call to readlink. In other words, need to replace:

source="$(readlink "${source}")"

with

source="$(readlink -f "${source}")"

For finding frameworks.sh path. Pods --> Target support files --> Pods-(Project_Name) --> frameworks.sh This second solution is from here: https://developer.apple.com/forums/thread/725230?login=true

9 Comments

this worked for me. For finding frameworks.sh path. Pods --> Target support files --> Pods-(Project_Name) --> frameworks.sh
@Jaykant I added that path to the answer
This has worked for me... Thanks.. I was getting error: Alamofire.framework" failed: No such file
the -f has already been added before without me changing it. but i still got the same error when building
@Bryan Lumbantobing did you get any solution for this. even for me -f has already been added still I got same error while building
|
57

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 script data

enter image description here

Solution2:

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

Select For install builds only option

enter image description here

Script:

"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/#####/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"

In the above script ##### is the app name, if required replace with your app name. If not, use below script.

"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"

Solution 3

And one more importent thing is you must set the path of the file properly.

Find the below example path.

You have multiple google services plist piles, in this case you are maintaining 2 different files. Your google service info plist file was under FireBase, Dev. In this case you must add these files path properly. Otherwise you will get the same error.

"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/#####/Firebase/Dev/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"

Solution 3 file structure:

enter image description here

8 Comments

Solution 2 works for me. Device Mac M2 , Xcode 14.1
First one worked for me. Not sure if it helped that I also did the second. Thanks for the tip!
Soln 1 is works for me Xcode 15 beta 5
Solution 2 works for me. Xcode 14.2
me too. I love you man. Does this for install builds only harms anything when checked?
|
51

Solution in 2024

Step 1: Open xcode and search for the following line

source="$(readlink "${source}")"

The file directory would be : ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh

Step 2: Replace the searched line in the code with -f

Before

source="$(readlink "${source}")"

Change this to:

source="$(readlink -f "${source}")"

7 Comments

Thanks for taking the time to properly explain rather than pasting directly from the Apple Forums. The main challenge was to actually locate where to add the -f
This works for me. The path was /ios/App/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh
I don't know why this worked, but it did! thank you. Macbook Pro, Apple M1pro, Xcode 14.3.1
Wow, this worked like charm, How to upvote this answer multiple times ?
Pure beauty of a help. thanks really
|
30

Warning: Legacy Build System is deprecated and will be removed in a further release.

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

Note - Its not the ideal solution.

6 Comments

That returns Permission Denied for Pods/Target Support Files directory
This might solve the problem but is not an ideal solution since XCode New Build System is designed to optimize the build process.
Thank you, this helped me to solve this issue on the old project.
You are not resolving the issue, you are just hiding them.
Changing the settings to Legacy Build System at least showed me the error messages. I fixed the issue and then set it to new build settings again Thank you Haseeb!
|
29

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.

2 Comments

This worked for me. I had the same issue, I was removing New Relic but still had an existing script in Run Script. Thanks
In my case it was "${PODS_ROOT}/FirebaseCrashlytics/run" under Run Scripts.
25

Xcode 12.2 solution: Go to:

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

1 Comment

It works but when it's and real deice but not I need to add arm64 again when need to use an emulator. My Xcode version is 12.5.1 and using Mac M1, real device, iPhone 7. any help.
19

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

1 Comment

Thank you! Other answers didn't work, but this one helped!
19

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"

2 Comments

For me it was going from "${PODS_ROOT}/Fabric/run" to "${PODS_ROOT}/FirebaseCrashlytics/run"
Wait sir, that works, can anyone explain why it does though?
16

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

2 Comments

same, i also restart my xcode
These are the things that make me think that react-native is not ready yet. I lost 2 hours on this and just restarting the Mac solved. Unbelievable
10

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

Comments

10

The reason

This build phase also lets you provide a list of input and output files. The script always runs when no input and output files are provided. When input and output files are provided, the script only runs if it has never been run before, one of the input files has changed, or one of the output files is missing

If you are using cocoapods, you may not be required to have an additional run script .

The solution

So the solution is remove the script as follows:

enter image description here

3 Comments

Will this cause problem when we try to deploy it on the real device?
This fixed my issue. I was integrating unity with my native iOS project.
This ruined my flutter app.
10

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

For Example: chmod +x (File name in the error)

In my case: chmod +x Pods-TestExample-frameworks.sh

2 Comments

Can u please give an example ? +x solution means what ?
@SwiftyCodes i'm referring to how to change the file permissions. look up how to use chmod to change file permissions
10

In terminal go to project path and follow the below steps

  1. pod deintegrate

  2. pod cache clean --all

  3. pod install

Comments

10

Command PhaseScriptExecution failed with a nonzero exit code is a general message and because of this you may not find a solution that will work for your case. the best way to go about this is to get the root cause of this error.

Steps to get root cause

  • Open Xcode

  • Go to "Show the Report navigator" enter image description here

  • Click on the last build with the error enter image description here

  • Now you can be able to read the root error. For me the root error was flutterfire not configured. Well, it was but i had to re-authenticate. enter image description here

2 Comments

same issue but reauthentication didn't work for me :(
did u fix the issue? or are u still having the issue?
9

In Xcode 12.4, after hours of try found the solution to this.

Go to Target > Architectures Set Build Active Architecture Only to YES and Excluded Architectures to x86_64 enter image description here

2 Comments

Thanks it worked with me after changing just the Build Active Architecture Only to YES however, do you have an idea if this modification has any consequences ?
after some investigations it seems like it's not recommended to change Build Active Architecture Only to Yes, as I believe it will only be valid for the architecture on which the app is currently running, that's to stay that this approach is good only if you are building a version for testing purposes maybe
9

XCODE 14.3

There are a number of reasons for this error, I encountered it with rsync issue when archiving my project.

There is an issue with Cocoapods now, because Xcode 14.3 is now using a relative path in its symlink for frameworks.

Either wait for release of Cocoapods version 1.12.1 or make this simple change in your Pods-APPNAME-frameworks.sh file:

Replace:

if [ -L "${source}" ]; then
echo "Symlinked..."
source="$(readlink "${source}")"
fi

With:

if [ -L "${source}" ]; then
echo "Symlinked..."
source="$(readlink -f "${source}")"
fi

Note that -f was added.

You can find this file in

Pods > Target Support Files > Pods-'Your-ProductName' > Pods-YourProductName-Frameworks.sh

Open the file in any text editor and make the change.

Original Source of this solution can be found in this Link

6 Comments

Please do not post duplicate answers.
I didn't see any answer mentioning it is a cocoapod issue. Besides the answer is detailed and helpful. A negative vote for that?
This is working well for me. +1 vote
putting back -f for Xcode 13.2 resurrected archive easy peasy :)
|
8

If your issue is run custom shell script cp embed pods frameworks fails than here is the answer for you

It seems like there is an issue on Xcode 14.3 and higher. There are open issues on iOS developer forum.

ref: https://developer.apple.com/forums/thread/725230?answerId=746897022#746897022

An idea could be to downgrade to 14.2 and see if it works.

Another workaround without downgrading: Open project in Xcode. Go to Pods -> Target Support Files -> Pods-YOUR_APP-Frameworks and change line 44 to below to

source="$(readlink -f "${source}")"

4 Comments

I am getting exactly same issue in xcode 14.3
Please do not post duplicate answers.
It was not duplicate Answer @HangarRash. Above answer was edited couple of days back it was not showing path for where to edit
life saver thanks, i come here twice or thrice a month 😅😂
7

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.

1 Comment

Getting rid of a space in a directory containing the project fixed this for us. Thanks.
7

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

Comments

6

If you experience this issue in flutter. Try running the application on a real iPhone device from other IDE like android studio or vs code.

The issue was flutter SDK missing iOS-profile-release.

So by running the flutter command

flutter run

It downloads the missing things before running and this solves the problem.

Comments

5

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

Comments

5

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.

Comments

5

There is an issue with Cocoapods now because Xcode 14.3 is now using a relative path in its symlink for frameworks.

Either wait for release of Cocoapods version 1.12.1 or make this simple change in your Pods-APPNAME-frameworks.sh file:

APPNAME is your Application name

you need to SEARCH and REPLACE:

  if [ -L "${source}" ]; then
    echo "Symlinked..."
    source="$(readlink "${source}")"
  fi

with

  if [ -L "${source}" ]; then
    echo "Symlinked..."
    source="$(readlink -f "${source}")"
  fi

Note that -f was added.

enter image description here

enter image description here

Comments

5

solution for me, none of these arch -x86_64 pod install and etc does not work until I did these steps:

  1. run sudo gem install ffi in terminal.

  2. then run arch -x86_64 pod install and build again.

and worked fine.

Comments

4

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

Comments

3

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.

1 Comment

In my case, I updated React Native version and during update, the app's Display name became empty. It worked when I assigned a Display Name in XCode
3

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

1 Comment

This worked, thank you. But what is the effect of removing that ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.