Aqib shahzad
Aqib shahzad

Reputation: 747

Xcode 14: Command PhaseScriptExecution failed with a nonzero exit code

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

Upvotes: 56

Views: 123977

Answers (15)

Ahsanwarsi
Ahsanwarsi

Reputation: 1023

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.

Upvotes: 0

Ali Abbas
Ali Abbas

Reputation: 711

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

set -e change with set +e

Upvotes: 0

Deepak Singh
Deepak Singh

Reputation: 1145

In my case

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

Upvotes: 0

Amiii
Amiii

Reputation: 379

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

Upvotes: 0

Sanket Vanani
Sanket Vanani

Reputation: 546

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.

Upvotes: 0

Levchenko
Levchenko

Reputation: 643

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!

Upvotes: 1

Stredsto
Stredsto

Reputation: 331

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

Upvotes: 21

themenace
themenace

Reputation: 2810

This issue was fixed in an Cocoapods update.

Just update to version >= 1.12.1

Upvotes: 3

Northern Captain
Northern Captain

Reputation: 1237

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.

Upvotes: 8

Raj Mohan
Raj Mohan

Reputation: 1237

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

Upvotes: 120

Ketan Ramani
Ketan Ramani

Reputation: 5783

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

Upvotes: 18

Engr.Aftab Ufaq
Engr.Aftab Ufaq

Reputation: 6394

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.

Upvotes: 0

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

Upvotes: 3

Ten
Ten

Reputation: 1656

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

Upvotes: 4

Thiago Loureiro
Thiago Loureiro

Reputation: 1143

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

enter image description here

Upvotes: 19

Related Questions