34

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

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Aqib shahzad
  • 491
  • 1
  • 4
  • 11
  • Check the packaages you have on your flutter project might some package are outdated – Arbiter Chil Sep 18 '22 at 07:41
  • 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. – Mitesh Baraiya Apr 25 '23 at 06:19

10 Answers10

92

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}")"
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
Raj Mohan
  • 957
  • 1
  • 6
  • 3
  • 3
    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.! – Pushpendra Apr 04 '23 at 12:56
  • 2
    It worked, but this will not be part of our code and will be generated by Pod. Is there any way for CI. – Ganesh G Apr 07 '23 at 10:30
  • 4
    Mine was in `ios/Pods/Target Support Files/Pods-{app_name}/Pods-{app_name}-frameworks.sh` as opposed to `Pods-Runner`. – I wrestled a bear once. Apr 19 '23 at 19:41
  • @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 RajMohan – Rizwan Walayat Apr 28 '23 at 11:24
  • Any fix that disappears when you run common maintenance commands like `pod install` is going to be a headache. – Mikael Grön May 25 '23 at 06:16
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
Ketan Ramani
  • 4,874
  • 37
  • 42
15

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

enter image description here

Thiago Loureiro
  • 1,041
  • 13
  • 24
9

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}")"
Stredsto
  • 111
  • 1
  • 4
5

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.

Northern Captain
  • 1,147
  • 3
  • 25
  • 32
  • 1
    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. – Mikael Grön May 25 '23 at 06:25
  • This also fixed the issue I was having on a Cordova build for Xcode 14 - thx – Elemental Jun 02 '23 at 11:45
  • 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://stackoverflow.com/a/75947102/13049584 ) too, but I'm not sure if that had any effect on this) – Amin Dannak Jul 19 '23 at 10:28
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

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://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
Ten
  • 1,426
  • 1
  • 14
  • 18
  • I've tried this approach but I didn't work for me – jlandyr Jul 25 '23 at 21:32
  • Tell me the details, I will try to help you. – Ten Aug 07 '23 at 03:08
  • 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! – Carl Smith Aug 13 '23 at 22:11
1

This issue was fixed in an Cocoapods update.

Just update to version >= 1.12.1

themenace
  • 2,601
  • 2
  • 20
  • 33
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.

Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47
0

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!

Levchenko
  • 611
  • 4
  • 6