6

Need you help please. 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
Taimoor Sikander
  • 605
  • 1
  • 3
  • 11
  • Can you please provide a screenshot of the error? This error is not enough the explain the reason. Also, please provide your Xcode version as well – Masroor Apr 10 '23 at 07:35
  • If you are using Xcode 14.3 then this is your solution. Because of the latest cocoapods changes archive is failing for all of the existing projects https://stackoverflow.com/a/75921492/5461816 – Masroor Apr 10 '23 at 07:38

3 Answers3

35

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

Maziar Saadatfar
  • 1,286
  • 1
  • 5
  • 11
15

As suggested by

@Maziar Saadatfar

Followed his 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
Taimoor Sikander
  • 605
  • 1
  • 3
  • 11
0

Add -f within this code source="$(readlink -f "${source}")"

file location ios/Pods/Target Support Files/Pods-Runner

You can add -f to your project file like this