216
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'
Hiren Dhamecha
  • 658
  • 5
  • 15
Emin Kotan
  • 2,273
  • 3
  • 9
  • 12

79 Answers79

185

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

kingPuppy
  • 2,937
  • 1
  • 18
  • 18
Anurag Sharma
  • 4,276
  • 2
  • 28
  • 44
  • 11
    can anyone explain why this answer work? also will this cause any unexpected behavior I should be aware of? – Nicolas Le Gorrec Mar 20 '20 at 17:12
  • 2
    @NickLeGorrec, Please check the below links to read about them: https://stackoverflow.com/questions/5913199/xcode-run-script-build-phase-run-script-only-when-installing-option https://stackoverflow.com/questions/6910901/how-do-i-print-a-list-of-build-settings-in-xcode-project – Anurag Sharma Mar 23 '20 at 17:46
  • 3
    Debug-installing on a device (build & run from Xcode) does not count as "installing". The run script only runs when archiving – Lal Krishna Aug 01 '20 at 06:02
  • 45
    now it's changed it's stated as run script: For install builds only – Shalabyer Feb 17 '21 at 14:09
  • 11
    that's work in build . but error showed when i Archive project again! – Meisan Saba Oct 10 '21 at 15:48
  • Can some one please send the code that needs to be added. i had this "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh" but looks like we are changing pods-Runner to Pods-Pod. @AnuragSharma – Mohamed Abdul-Malik Apr 25 '22 at 07:48
  • I'm white labelling the existing App, so I have changed cp -r "$PATH_TO_GOOGLE_PLISTS/GoogleService-Qa-Info.plist" to cp -r "$PATH_TO_GOOGLE_PLISTS/GoogleService-Info.plist" – Prabakaran Muthusamy May 04 '22 at 13:23
  • This crashes the app on startup with error "dyld[45533]: Library not loaded:.......(no such file, not in dyld cache)" as the Pod isn't installed. – sudoExclaimationExclaimation Mar 29 '23 at 20:37
  • 4
    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: https://stackoverflow.com/questions/53289524/xcode-10-2-1-command-phasescriptexecution-failed-with-a-nonzero-exit-code/75945651#75945651 – Schwarz Software Apr 17 '23 at 01:31
  • This makes the app crash when you try to run it on a device from xcode. Def. not the correct answer! I'm on xcode 14.3.1, and ever since I updated, I'm getting this error when trying to archive. – Mikkel Cortnum Jun 22 '23 at 12:52
122

Go to

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

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

david m lee
  • 2,547
  • 26
  • 14
Isaac Smorong
  • 1,393
  • 1
  • 8
  • 11
104

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

gignu
  • 1,763
  • 1
  • 14
  • 24
Abhishek Bedi
  • 5,205
  • 2
  • 36
  • 62
57

This could happen due to a recent 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

Schwarz Software
  • 1,114
  • 8
  • 22
42

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

Naresh
  • 16,698
  • 6
  • 112
  • 113
29

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.

Ankur Lahiry
  • 2,253
  • 1
  • 15
  • 25
Haseeb Javed
  • 1,769
  • 17
  • 20
  • 3
    That returns Permission Denied for Pods/Target Support Files directory – pixel Jan 13 '20 at 22:09
  • 22
    This might solve the problem but is not an ideal solution since XCode New Build System is designed to optimize the build process. – Abhishek Bedi Jan 18 '20 at 08:35
  • 1
    Thank you, this helped me to solve this issue on the old project. – derpoliuk Nov 21 '20 at 16:29
  • 5
    You are not resolving the issue, you are just hiding them. – iPeter Nov 25 '20 at 20:01
  • 4
    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! – MBH Mar 18 '21 at 13:04
  • This solution helped me to find the actual issue, yarn was missing in my case under FBReactNative component. Once fixed reverted back to new settings. – Dobin Jun 17 '21 at 10:59
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.

Harshal Karande
  • 476
  • 4
  • 9
24

Xcode 12.2 solution: Go to:

  1. Build settings -> Excluded Architectures
  2. Delete "arm64"
Andrei Traciu
  • 267
  • 2
  • 2
20

Solution in 2023

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}")"
Md Abu Saif
  • 429
  • 2
  • 5
  • 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` – daspianist May 11 '23 at 20:00
  • This works for me. The path was `/ios/App/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh` – Sampath Jun 02 '23 at 09:53
  • I don't know why this worked, but it did! thank you. Macbook Pro, Apple M1pro, Xcode 14.3.1 – Aaron Krauss Jun 07 '23 at 15:22
  • Wow, this worked like charm, How to upvote this answer multiple times ? – Nasir Aug 27 '23 at 08:15
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"
Rajat Mishra
  • 995
  • 7
  • 18
13

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

Mike Skinner
  • 191
  • 1
  • 7
13

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

Pau Ballada
  • 1,491
  • 14
  • 13
11

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

Abir Ahsan
  • 2,649
  • 29
  • 51
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

Shahid Aslam
  • 2,585
  • 3
  • 24
  • 31
bengoesboom
  • 2,119
  • 2
  • 23
  • 27
10

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

  • 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 ? – Sherif Samir Jan 13 '23 at 13:42
  • 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 – Sherif Samir Jan 13 '23 at 14:36
9

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

8

In terminal go to project path and follow the below steps

  1. pod deintegrate

  2. pod cache clean --all

  3. pod install

iTALIYA
  • 972
  • 8
  • 14
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}")"
Kuntal Gajjar
  • 792
  • 6
  • 12
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

iDecode
  • 22,623
  • 19
  • 99
  • 186
6

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.

Krekin
  • 1,516
  • 1
  • 13
  • 24
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.

Yahya
  • 210
  • 2
  • 12
6

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

Naheed Naveed
  • 87
  • 1
  • 3
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.

Kamran Gasimov
  • 1,445
  • 1
  • 14
  • 11
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.

4

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

Umair Raees
  • 129
  • 6
4

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
Dharman
  • 30,962
  • 25
  • 85
  • 135
Dick Thunder
  • 378
  • 3
  • 17
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

chenop
  • 4,743
  • 4
  • 41
  • 65
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.

  • 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 – Ajay Apr 20 '23 at 17:19
3

If you newer version of Xcode you can do check this box Targets -> Build Phases -> Run Script ->check box>For install builds onlyenter image description here

3

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

Nitin
  • 1,383
  • 10
  • 19
2

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. :)

Mohammad Zaid Pathan
  • 16,304
  • 7
  • 99
  • 130
2

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
kat
  • 5,645
  • 4
  • 19
  • 35
2

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.

Zou
  • 313
  • 3
  • 6
1

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

Chandan Jee
  • 5,440
  • 4
  • 16
  • 24
1

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"
José María
  • 2,835
  • 5
  • 27
  • 42
Balashekar
  • 121
  • 2
  • 11
1

Remove a space in fileName.

For example, from:

/Users/user/Desktop/My Projects/TestProject/

to

/Users/user/Desktop/MyProjects/TestProject/
                      ^ space removed
blackgreen
  • 34,072
  • 23
  • 111
  • 129
1

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

Jaykant
  • 349
  • 4
  • 11
1

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
steveny909
  • 95
  • 1
  • 3
  • 10
1

When I encountered this error, it was only when I was archiving. Running and building worked fine but archiving kept throwing the error. What worked for me was updating my cocopods:

sudo gem update cocoapods
Allen
  • 301
  • 2
  • 4
1

Actually I had this issue in building my first app looks like there is something changed in the new flutter version 2.5.3 the latest because when I downgrade to 2.5.0 I build on my simulator & my iPhone also with no issues

bebars1998
  • 11
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 30 '21 at 05:19
  • Upgrading to 2.8.0 does not seem to work either. Anyone who could help? – Siyah Dec 09 '21 at 15:23
  • Actually I think flutter have some fetal issues in the new versions so if you are just learning use an older version or if you want to make a real app use react native for now – bebars1998 Dec 10 '21 at 16:08
1

Nothing worked for me until going to VSCode(IDE APP), and ios/App/App.xcodeproj/project.pbxproj that file, and searched EXCLUDED_ARCHS = arm64, and delete that line,

I did the same thing from Xcode, like go to target>build settings, exclude arc thing, and deleted arm64 from there, didn't work before, but deleting from VSCode worked, weird

1

Delete these Folders/Files

  1. PodFile
  2. PodFile.lock
  3. Pods
  4. Runner.Xcworkspace

Select IOS device/Simulator From Android Studio If build Successfully then build app from XCode

If get new error then

  1. open ios/podfile file
  2. add this line "platform :ios, '12.0'"
  3. open terminal
  4. write "cd ios"
  5. write "pod update"

Then build again from Android Studio If build Successfully then build app from XCode

Atif Ahmad
  • 61
  • 1
  • 5
  • There are **54 existing answers** to this question, including a top-voted, accepted answer with over **one hundred votes**. Are you _certain_ your solution hasn't already been given? If not, why do you believe your approach improves upon the existing proposals, which have been validated by the community? Offering an explanation is _always_ useful on Stack Overflow, but it's _especially_ important where the question has been resolved to the satisfaction of both the OP and the community. Help readers out by explaining what your answer does different and when it might be preferred. – Jeremy Caney Mar 18 '22 at 02:06
1
  1. delete node_modules folder
  2. delete Pods folder under ios
  3. run yarn cache clean
  4. run yarn
  5. run cd ios & pod install
  6. enjoy build
wol
  • 142
  • 1
  • 14
1

If you need to run the project in a physical device, none of the answers worked for me in Xcode 13.3. What worked for me was deleting VALID_ARCHS = x86_64; from project.pbxproj everywhere. but this won't let you run in simulator

  • Removing x86_64 from VALID_ARCHS will prevent your app from running in the Simulator on Intel Macs. Probably one of your library dependencies is missing the x86_64 slice. – David Gish Apr 13 '22 at 03:51
1

Facing the same issue check if the parent directory name of your project has no space for Example my project name todoapp is inside My App directory change it to MyApp and it should work.

1

Solution for Flutter users

In case your app was developed using Flutter, the above steps worked for me:

Run:

  1. flutter run
  2. flutter pub get
  3. run pod install inside the iOS folder
  4. build
genericUser
  • 4,417
  • 1
  • 28
  • 73
1

for flutter developers: make sure that dart:html or dart:js packages are not being imported in any file.

aligur
  • 3,387
  • 3
  • 34
  • 51
1

I was struggling with a similar problem in Xcode 14 (error build: Command PhaseScriptExecution failed with a nonzero exit code). This error seems to be a very general description of some more detailed error but I didn't realize it for some time.

Finally I found the description of the error in Build log, but it was really frustrating to navigate there. I recommend you to read the detailed error first and then act. Xcode is not so intuitive... Follow this and navigate there. I hope that it saves time to someone.

Vít Kapitola
  • 499
  • 1
  • 5
  • 9
1

More general debugging help

Note that you can double-click the error in the build log to get more details:

XCode build log

Then you will get a tab with the current build log containing more information. Read it really carefully to see if there is a more specific description of the problem there.

XCode error log to read carefully

In my case I was using Kotlin Multiplatform Mobile and had an error in my build configuration flags there.

If double-clicking does not work: Apparently, you sometimes need to retry building by pressing Cmd + B before being able to double-click the message. I sometimes had to do this multiple times before I could inspect the logs this way.

palsch
  • 5,528
  • 4
  • 21
  • 32
1

Another possible problem solution for React Native developers: check if metro port is not busy!

When building in debug mode - make sure port 8081 for metro packager is free, not busy for other app (in my case antivirus agent after restart) or if previous metro service is not hanged there.

Check for processes listening on given port numbers:

sudo lsof -i -P | grep LISTEN | grep :$PORT

If found something on port 8081 - kill it with it's pid id

sudo kill -9 {PID_ID}
deevee
  • 1,550
  • 15
  • 21
1

For me, the error is because of Port 8081 already in use, packager is either not running or not running correctly

Use the following answer to solve this problem:
https://stackoverflow.com/a/70046852/12280908

In Linux / Mac,

Open terminal and run the command to check whether any program running on the port 8081.

sudo lsof -i :8081

Assume that if you got output something like this,

COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node     59 root   18u  IPv4 609033      0t0  TCP localhost:8081 (LISTEN)

Then kill the program with ID 609033 using the following command,

sudo kill -9 59
ZIRES
  • 276
  • 3
  • 10
0

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.

Piotr Badura
  • 1,574
  • 1
  • 13
  • 17
0

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.

0

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

Vadim F.
  • 881
  • 9
  • 21
0

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.

starball
  • 20,030
  • 7
  • 43
  • 238
Gurbela
  • 1,184
  • 2
  • 16
  • 40
0

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.

Pranav Kasetti
  • 8,770
  • 2
  • 50
  • 71
0

I switched from Firebase CocoaPods to Swift Package Manager.

The old symbols upload script still was listed in the 'Build Script' phase.

Delete this and replace with whatever is recommended. At time of publishing it was ' "${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"'.

0

what worked for me was going to Excluded Architectures and then deleting arm64 on each of the options provided and then clean build

cherucole
  • 560
  • 7
  • 15
0

In my case, my VALID_ARCHS was containing x86_64. After deleting it, my project has built without problems.

0

In my case "pod 'FirebaseUI/Facebook'" was causing Firebase to install an earlier version (Terminal: "Installing Firebase 2.5.1 (was 8.10.0)").

Removing "pod 'FirebaseUI/Facebook'" from the pod file fixed it.

LucasKarlsson
  • 1,021
  • 1
  • 10
  • 16
0

Solution for React Native: Run from project root

(Modify "PROJECTNAME" by the name of the project)

cd iOS

cd Pods/Target\ Support\ Files/Pods-PROJECTNAME

chmod 755 Pods-PROJECTNAME-resources.sh
0
error SyntaxError: 
Component has already been declared. (68:2)

See Xcode logs if you see the above error,then check your navigation I think you added a double component in your project navigation flow

0

Specifically for Flutter!

It turned out to be because I move a folder with .dart files to a new location and imports referencing the old directory were still in the code. Deleting those imports fixes the problem.

Unfortunately, with VSCode, all you get is a warning that the import is not used, not that it doesn't exits! Opening Xcode revealed these errors.

mauriii
  • 486
  • 2
  • 6
  • 17
0

I encountered this error in the context of a React-Native project running on iOS. I did several things so it's hard to know which one fixed it:

  • Make sure you don't have errors in your bash or zshrc profile -> I had a error related to my jdk. You will know if when opening a terminal window it shows an error/warning
  • Make sure you don't have spaces in the path
  • If you are using Firebase, make sure your GoogleService-Info file is in the ios folder and not in the ios>project folder
  • Do not keep the project in an iCloud folder, especially if you are low on space. I suspect this was a big factor for mine

Finally, my worked when doing these and running react-native 0.67.2. The newer version on it's own didn't fix it, I had to do at least one of these other assertions to get it working.

Things to consider:

  • Running the project in Xcode will usually give you more insight into the problem
  • Clearing the Xcode build folder wasn't enough on it's own to fix it but when trying a potential solution it is important you do it (and potentially also pod deintegrate && pod install) to make sure there are no traces of the previous ios build.
  • I am running node version 16.13, running node 17 gave me different errors and I wouldn't recommend it to date. I am running macOS Monterrey and Xcode 13.2.1, but I tried on BigSur and also Xcode 12.5.1 and the still got the error.

For react-native, this error is discussed in length here: https://github.com/facebook/react-native/issues/31181

0

For Mac M1, remove arm64 in build settings fix the issue on real device build. I add this string when run with simulator.

enter image description here

Zhou Haibo
  • 1,681
  • 1
  • 12
  • 32
0

I am using multi development environments. One in the office and one at home. The office is the one that I continually use and keep in shape. The one at home I rarely use and hence it becomes out of sync. I am not speaking about the repo being out of date but rather the development environment itself.

So, cutting into chase, my error was more related to new updates resulting from deprecated/obsolete classes which are not available in mu home environment. in office I upgraded to Flutter 3.3 but at home I was still using Flutter 3.0. so there were few new things introduced in 3.3 which I started using and which do not exist in 3.0.

The solution was to upgrade Flutter and then build again. run flutter upgrade in terminal.

rashidotm
  • 392
  • 2
  • 12
0

I encountered this issue while building the example ios project using react-native-builder bob

Two ways to fix the issue

  1. https://stackoverflow.com/a/60090102/7152965 the result mentioned above
  2. rename the index.ts file to index.js file in example directory
fahad991
  • 452
  • 3
  • 8
0

This issue is literally related to your Xcode build phase script.
In my case, In the Target -> Build Phases -> Bundle React Native code and Images, I found some issue in my build script for Sentry.
It was the path that node binary is located. My script wanted node to be in usr/local/bin/node but my path was opt/homebrew/bin/node something like that.
So I just uninstalled node via homebrew and installed node directly from their homepage.

starball
  • 20,030
  • 7
  • 43
  • 238
Junho Lee
  • 198
  • 1
  • 10
0

I'm try After trying almost ALL ways of fixing this issue I came across this command:

flutter run -v > log.txt

This command creates file which logs all events of your build.

Among this long text I found I found a line with a word "error". I guess it's easier just to press cmnd + F and type "error" or "exception" to find the key lines.

Anyway it gave me a key that one of packages doesn't support null-safety. My solution was removing this package.

0

In my case, the problem occurred because I changed my Intel Core i5 processor to an Apple m2 processor.

Please follow the below steps -

Step 1 - Open Finder -> Applications -> Xcode (right click) -> Get Info -> Open with Rosetta check the box

Step 2 - Open Finder -> Applications -> Utilities -> Terminal (right click) -> Open with Rosetta.

Step 3 - Restart the machine. Then it will ask for Rosetta installation. Install Rosetta. Then run Xcode.

Shabnam Siddiqui
  • 579
  • 4
  • 13
Gleny Rebellow
  • 111
  • 1
  • 8
0

I bumped into this issue when upgrading react native from 0.68 to 0.69.

I was missing ios/.xcode.env.local file. Just added result of which node there for NODE_BINARY: export NODE_BINARY="/opt/homebrew/bin/node" there as in ios/.xcode.env and problem was fixed;

David Chanturia
  • 83
  • 1
  • 11
0

In XCode 14.3 release, this issue is causing most of the time. The below-mentioned solution works for me.

  1. First you have to Clean Project using command+shift+k
  2. Now re-install pods, and increase the library development target if required. (in Xcode 14.3, the minimum requirement is iOS<= 11.0)
  3. Find source="$(readlink "${source}")" globally and replace with source="$(readlink -f "${source}")" on all the places.
  4. Now try to archive.

if it does not works, then delete Podfile.lock and Pods folder from your project root path. and then start from 2ns step.

starball
  • 20,030
  • 7
  • 43
  • 238
akmoji
  • 79
  • 1
  • 2
0

what helped me was what I put here, before there was a configuration from podsenter image description here

dubinsky
  • 31
  • 4
0

XCODE 14.3

I got this error after upgrade both XCode (13.x => 14.3) and Flutter (2.1 => 3.10) when I tried to archive my project. Normally, I can archive a new flutter application without issues. The reason I got error, I think there was a significant difference between the two versions of flutter. The solution I have implemented below may be useful for those who get an error on a particular project.

Solution:

(We need old version of project which worked because we need the Runner folder which is in ios folder from this old project.)

  1. Don't forget to backup your project first.
  2. Remove the ios folder from the new project.
  3. Open your project directory in terminal and execute flutter create . This command will create a new ios folder.
  4. Open old version of project and copy the Runner folder from ios folder, and delete new Runner folder from ios folder in new project, and paste it old Runner folder there.
  5. flutter clean
  6. flutter pub get
  7. cd ios
  8. pod install

After these operations try archive again the project.

shalom
  • 191
  • 1
  • 1
  • 10
0

For me, the problem was the custom Framework linked to my project which was generated via the Swift OpenAPI Generator plugin.

I followed and implemented the tutorial, and had no issues building in Xcode 15, but when trying to run the app in Xcode 14, I got this error.

I fixed the problem by deleting all instances of my custom, OpenAPI generating framework in Targets -> Build Phases.

Plato
  • 111
  • 2
  • 7
-1

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!

Neph
  • 1,823
  • 2
  • 31
  • 69
-1

Fix Xcode Command PhaseScriptExecution failed with a nonzero exit code

The Xcode 11+ “Command PhaseScriptExecution failed with a nonzero exit code” error message can be concerning for developers. This may mean that an application or script is not running properly. Some potential solutions can be attempted to troubleshoot the issue.

Solution #1 Open the Xcode project folder in your Terminal app. Enter and execute the following command: pod deintegrate Execute this command: pod install Re-open Xcode > go to Product > Clean Build Folder. Run your app again.

Solution #2 Head over to Keychain Access. Select Lock & unlock again from the login option. Open Xcode > Clean Xcode Project > Run your build again. If neither of those solutions works, then it is possible to reach out to Apple for support.

Sources : Fix nonzero exit code

ArNo
  • 2,278
  • 1
  • 22
  • 19
-1

I was facing the same issue, spend days on this but still no results.phasescript execution issue Even I reinstalled the xcode, also deleted all the caches At the end I restored my mac. Also upgraded all the softwares to there latest. Hope this will solve your issue since it solved mine. The major issue behind this was it was not able to upload the debug sentry symbols, maybe i modified any major file. So restoring it solved the issue, since it was just a caching issue

DriVe
  • 33
  • 8
-1

If you are here because you recently updated XCode to v14.3 or 14.3.1 like me, a very simple solution is to go and download v14.2 and make your archives through this older version of XCode. Solves the problem in an instant. No need to do any hacking in the config files whatsoever. Until we wait for a fix in the new release of CocoaPods or XCode, this is the solution I chose.

https://developer.apple.com/download/all/?q=14.2

Mikkel Cortnum
  • 481
  • 4
  • 11