56

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

2
  • Check the packaages you have on your flutter project might some package are outdated Commented Sep 18, 2022 at 7:41
  • 2
    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. Commented Apr 25, 2023 at 6:19

15 Answers 15

121

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}")"
Sign up to request clarification or add additional context in comments.

8 Comments

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.!
It worked, but this will not be part of our code and will be generated by Pod. Is there any way for CI.
Mine was in ios/Pods/Target Support Files/Pods-{app_name}/Pods-{app_name}-frameworks.sh as opposed to Pods-Runner.
Any fix that disappears when you run common maintenance commands like pod install is going to be a headache.
source="$(readlink -f "${source}")" its already there but still i'm facing error.
|
21

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}")"

2 Comments

this worked for me also I am running xcode Version 15.0.1
The newer code with -f appears to be the default now as I tracked this down and it was already there.
19

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

enter image description here

5 Comments

It is useless when installing builds.
it will be disable your script. That can make your code run wrong.
it is not acceptable answer for this question.
this was accepted back then without the other answers when this solution was feasible and worked. @KhurshidAnsari
@Akhil this was an old answer that worked at that time, I totally understand you. Doesn't make sense you come right now and say "can't be accepted".
18

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

3 Comments

does not work..
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.
Worked for me you glorious wizard!
8

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.

4 Comments

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.
This also fixed the issue I was having on a Cordova build for Xcode 14 - thx
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 ( stackoverflow.com/a/75947102/13049584 ) too, but I'm not sure if that had any effect on this)
This worked for me on react native with xcode 14
4

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://stackoverflow.com/questions/53289524/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

4 Comments

I've tried this approach but I didn't work for me
Tell me the details, I will try to help you.
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!
The reverse worked for me. I had installed Crashlytics using CocoaPods and not SPM and so the solution was to use "${PODS_ROOT}/FirebaseCrashlytics/run" instead of the alternative, which is what the official dox have written. This is a solid answer.
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

Comments

3

This issue was fixed in an Cocoapods update.

Just update to version >= 1.12.1

1 Comment

I have the same version of cocoapods but the problem persist
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!

Comments

1

In my case

Worked for me was to delete .xcode.env.local and start the whole process again

Comments

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.

Comments

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.

Comments

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

Comments

0

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

set -e change with set +e

Comments

0

I encountered the same issue. Here's what worked for me; I added the following in the Podfile post_install section:

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

Then, I ran the pod deintegrate command followed by pod install.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.