Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Error PhaseScriptExecution failed with a nonzero exit code

I've created flutter app and now want to create archive for distribution in Xcode 14.3.

Issue

  1. Archive is disabled.
  2. Getting this error with build failed PhaseScriptExecution failed with a nonzero exit code

Already tried

  1. Pod Install
  2. Clean build folder
  3. 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.

NOTE Head over to Keychain Access.Select Lock & unlock again from the login option is disabled. How to enable it?

Looking forward for your help.

SCREENSHOT enter image description here

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
like image 565
Taimoor Sikander Avatar asked Aug 31 '25 15:08

Taimoor Sikander


2 Answers

You should search this file in your project:

Pods-[your-project-name]-frameworks.sh (...-frameworks.sh)

and edit this section:

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

to:

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

source="$(readlink "${source}")" -----> source="$(readlink -f "${source}")"

Workaround is to update all the generated ...-frameworks.sh files to add the -f flag to the call to readlink. In other words, replace

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

with:

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

enter image description here

This link maybe help you:
https://github.com/CocoaPods/CocoaPods/issues/11808

like image 115
Maziar Saadatfar Avatar answered Sep 03 '25 06:09

Maziar Saadatfar


Followed @Maziar Saadatfar's instructions as stated in step 1 below and after this, one more thing that I have to do as stated in step 2.

  1. You should search this file in your project:

Pods-[your-project-name]-frameworks.sh (...-frameworks.sh)

and edit this section:

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

to:

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

source="$(readlink "${source}")" -----> source="$(readlink -f "${source}")"

Workaround is to update all the generated ...-frameworks.sh files to add the -f flag to the call to readlink. In other words, replace source="$(readlink "${source}")" with source="$(readlink -f "${source}")"

  1. Open Xcode - Click on Runner(Top one) Select the Runner from "PROJECT" Not from "TARGETS" Select configuration And update all the modes as this photo enter image description here
like image 28
Taimoor Sikander Avatar answered Sep 03 '25 05:09

Taimoor Sikander