Xcode 14: Command PhaseScriptExecution failed with a nonzero exit code
Asked Answered
W

12

47

After updating my Xcode to the version 14.0, I am getting this error:

Command PhaseScriptExecution failed with a nonzero exit code

If anyone knows how to resolve it, please let me know.

screenshot of Xcode

Woodley answered 18/9, 2022 at 7:11 Comment(2)
Check the packaages you have on your flutter project might some package are outdatedTuatara
I am using an M1 chip. When running on a physical device, I was able to clear this error by removing 'arm64' from the excluded architectures. However, when running on a simulator, I had to add 'arm64' back in.Nightingale
D
18

Click properties on the project, go to build phases and check the option "For install builds only"

enter image description here

Disject answered 27/9, 2022 at 12:21 Comment(4)
It is useless when installing builds.Briney
it will be disable your script. That can make your code run wrong.Briney
it is not acceptable answer for this question.Bragdon
this was accepted back then without the other answers when this solution was feasible and worked. @KhurshidAnsariDisject
K
116

Search for the following line in your project, it must be in ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh file.

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

Replace that with:

source="$(readlink -f "${source}")"
Kell answered 3/4, 2023 at 16:3 Comment(7)
Thank you @Raj Mohan for finding this. But what is the meaning of this line? Do you have any idea of this or you can give me more info on this. It will be grate and helpful thank you Mr.!Cheops
It worked, but this will not be part of our code and will be generated by Pod. Is there any way for CI.Burletta
Mine was in ios/Pods/Target Support Files/Pods-{app_name}/Pods-{app_name}-frameworks.sh as opposed to Pods-Runner.Robalo
@Iwrestledabearonce. Yes you are right about the file path. I believe "Runner" is the default project name created by Flutter. This error seems to have appeared after updating to the latest XCode 14.3 and installing Flutter. It was fixed with the solution provided by RajMohanKlimt
Any fix that disappears when you run common maintenance commands like pod install is going to be a headache.Selflove
this answer always worked for me but right now it's working with this projectVerein
It worked and surely saved me hours. Thanks for sharing this. You made my day!Obvert
D
18

Click properties on the project, go to build phases and check the option "For install builds only"

enter image description here

Disject answered 27/9, 2022 at 12:21 Comment(4)
It is useless when installing builds.Briney
it will be disable your script. That can make your code run wrong.Briney
it is not acceptable answer for this question.Bragdon
this was accepted back then without the other answers when this solution was feasible and worked. @KhurshidAnsariDisject
M
18

For the people facing error in cordova.

In your xcode, Go to PODS folder :
Target Support Files => Pods-{Your Project} => Pods-{Your Project}-frameworks

Change

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

this :

source="$(readlink -f "${source}")"
Mylander answered 20/4, 2023 at 6:45 Comment(3)
Excellent. WorksImputable
this worked for me also I am running xcode Version 15.0.1Femininity
The newer code with -f appears to be the default now as I tracked this down and it was already there.Cytherea
B
17

Those who are facing this issue after updating your Xcode 14.2 to 14.3 (14E222b) try the below steps to run & archive app.

  1. First upgrade your flutter version to 3.7.10 because this issue fixed in 3.7.10 (Check here)

  2. From Xcode Runner -> PROJECT (Runner) -> Info -> Deployment Target -> iOS Deployment Target -> Set to 12.0 (Minimum)

enter image description here

  1. From Xcode Runner -> TARGETS (Runner) -> General -> Minimum Deployments -> iOS -> Set to 12.0 (Minimum)

enter image description here

  1. From Xcode Pods -> PROJECT (Pods) -> Info -> Deployment Target -> iOS Deployments Target -> Set to 12.0 (Minimum)

enter image description here

  1. From Xcode -> Pods (Expand) -> Target Support Files -> Pods-Runner -> Pods-Runner-frameworks

Change

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

with

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

enter image description here

From your flutter Project -> ios -> Podfile

Change

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

with

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
         end
    end
  end
end
Brummett answered 6/4, 2023 at 7:56 Comment(3)
does not work..Sheikh
Nice answer, it's worked for me in direct native iOS app. I have update my Xcode in to 14.3 then I got this issue and it's resolved. I have replaced only this line source="$(readlink -f "${source}")" it's working for me.Estonian
Worked for me you glorious wizard!Perpetua
H
6

I do not use flutter but I faced similar problem with Alamofire in my project. I didn't want to change the pod scripts as they are generated every time you install the pods. In my case the issue was fixed by updating the cocoapods to the latest and then re-generating the pods stuff:

sudo gem install cocoapods #update cocoapods to the latest
pod deintegrate
pod repo update
pod install

Don't forget to close your XCode before running these commands.

Hawkinson answered 2/5, 2023 at 20:1 Comment(3)
This is the right mentality. Changing ephemeral files is a headache. I'm facing the same issue, not using flutter nor Alamofire, and have yet to figure out whats wrong but your solution didn't work for me.Selflove
This also fixed the issue I was having on a Cordova build for Xcode 14 - thxTurbellarian
was having the same issue with react native. all I had to do was updating the cocoapods (to be totally honest, I did the step 2 to 4 from this answer ( https://mcmap.net/q/89125/-xcode-14-command-phasescriptexecution-failed-with-a-nonzero-exit-code ) too, but I'm not sure if that had any effect on this)Otherwise
S
3

On my side this issue appeared when i change my computer and issue was caused by Apple Silicon processor. When i start to use m1 pro, i did not check the installation page i directly intalled flutter via Fvm. When i check the installation page i saw there are a few steps to install flutter on Apple Slicon. And these steps fixed the issue;

sudo softwareupdate --install-rosetta --agree-to-license

ref: https://docs.flutter.dev/get-started/install/macos

Sculptress answered 6/1, 2023 at 11:21 Comment(0)
E
3

This issue was fixed in an Cocoapods update.

Just update to version >= 1.12.1

Estuary answered 12/5, 2023 at 9:0 Comment(1)
I have the same version of cocoapods but the problem persistRanch
B
2

Maybe the problem is with "Run script"

Ex: I did change firebase crashlytics from "pod" to "Packeges". But I not change script. I have tried all the solutions in

"https://mcmap.net/q/89350/-xcode-10-2-1-command-phasescriptexecution-failed-with-a-nonzero-exit-code"

My solutions is change TARGETS -> Build Phases. In the script field form

"${PODS_ROOT}/FirebaseCrashlytics/run"

to

"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"

In short the problem is your script, do it right

If Scrip is install builds only. U need Targets -> Build Phases -> Run Scrip -> check "For install builds only"

Ex:

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
Briney answered 7/10, 2022 at 2:18 Comment(3)
I've tried this approach but I didn't work for meRanch
Tell me the details, I will try to help you.Briney
I fixed the error by changing "${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run" to "${PODS_ROOT}/FirebaseCrashlytics/run" Still, your answer was a big help!Acclamation
S
1

I got this error when I tried to make an archive for AppStore. In my case, I tried everything possible, but only the following actions worked.

The details of the error indicate that it is related to Firebase.

Pods/FirebaseCrashlytics/upload-symbols: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

  1. The Mac on which I work is not on the new M chip. So the first thing I did was run xCode through Rosseta(This is important to do) enter image description here

  2. Reinstall Firebase using SPM Swift Package Manager

  3. Remove all from Run Script enter image description here

I hope this will help someone!

Sephira answered 13/8, 2023 at 16:57 Comment(0)
P
0

I have removed a dependency from my project but forgot to remove that import in App.js. due to. which this issue arises. after looking carefully. to the error message notified that after removing that. dependency form App.js project run successfully.

Propene answered 22/3, 2023 at 12:39 Comment(0)
S
0

I was getting this issue multiple times and once I checked the available storage of my Macbook. It was full and no space left on the device.

I just cleared an unusual file and freed some storage and the error disappeared. I hope this solution works for you too.

Schumer answered 14/9, 2023 at 5:50 Comment(0)
P
0

I am using Xcode Version 15.3 and I got the same issue.

enter image description here

Command PhaseScriptExecution failed with a nonzero exit code

I tried many solutions but nothing worked. However, I found that my Project -> Runner -> Configurations -> Bassed on Configurations was the reason for this error on Xcode. I changed each of my Bassed on Configurations sets from

  • Pods-Runner.debug into Debug,
  • Pods-Runner.release into Release and
  • Pods-Runner.profile into Release.

Changing these solved my issue.

enter image description here

Proem answered 25/3, 2024 at 6:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.