32

I'm trying to archive my flutter app to export it to the Apple Store. The app can be run without any problems, but the archiving process result with a fail.

Xcode is at the latest version that i can download (Version 14.3 (14E222b)) Flutter is updated

I've tried theses commands to try to remove the problem :

flutter upgrade
flutter clean
flutter pub get
cd ios
pod deintegrate
rm -f Podfile.lock
pod install
pod update
pod install
sudo gem install cocoapods
sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc

After these commands i go into Xcode, delete DerivedData, Clean Build Folder, change Minimum Deployment into Pod > FMDB > General > Minimum Deployment > set to 12.0

And now I test to build an Archive.

After 30 seconds (average), i've got this error :

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/mateo/Library/Developer/Xcode/DerivedData/Runner-dehetosspbhbthhgdgvjmdurocom/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-B1164030238D389C328552D1.sh (in target 'Runner' from project 'Runner')
    cd /Users/mateo/Documents/Dev/App-VE-app/ios
    /bin/sh -c /Users/mateo/Library/Developer/Xcode/DerivedData/Runner-dehetosspbhbthhgdgvjmdurocom/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-B1164030238D389C328552D1.sh

mkdir -p /Users/mateo/Library/Developer/Xcode/DerivedData/Runner-dehetosspbhbthhgdgvjmdurocom/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/Runner.app/Frameworks
Symlinked...
rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/FMDB.framework" "/Users/mateo/Library/Developer/Xcode/DerivedData/Runner-dehetosspbhbthhgdgvjmdurocom/Build/Intermediates.noindex/ArchiveIntermediates/Runner/InstallationBuildProductsLocation/Applications/Runner.app/Frameworks"
building file list ... rsync: link_stat "/Users/mateo/Documents/Dev/App-VE-app/ios/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/FMDB.framework" failed: No such file or directory (2)
done

sent 29 bytes  received 20 bytes  98.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/810eba08-405a-11ed-86e9-6af958a02716/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code
Matancy
  • 429
  • 4
  • 5
  • 1
    Does this answer your question? [Command PhaseScriptExecution failed with a nonzero exit code when archiving](https://stackoverflow.com/questions/75928909/command-phasescriptexecution-failed-with-a-nonzero-exit-code-when-archiving) – HangarRash Apr 10 '23 at 19:55

4 Answers4

109

Please open xcode and click Pods-Runner-frameworks file on left panel.

enter image description here

go to 44. line

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

change to (add -f)

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

Note : Please don't forget the space after '-f'

enter image description here

Clean build folder and run again.

Zorkan Erkan
  • 1,233
  • 1
  • 5
  • 13
19

Update cocoapods to 1.12.1. Then do a new 'pod install'

Greg Anderson
  • 540
  • 4
  • 14
  • 2
    thanks! (simply run `brew upgrade cocoapods` to check if you've installed with brew, otherwise check https://stackoverflow.com/questions/39481636/updating-to-latest-version-of-cocoapods) – bersling May 19 '23 at 07:30
  • Wow! Works like magic. So this seems to be a bug that has been fixed by CocoaPods. – awmleer Jun 13 '23 at 03:42
  • This worked for me but I actually had to uninstall cocoapods first. I followed this instruction: https://stackoverflow.com/questions/66585376/undefined-method-request-for-nilnilclass-when-using-gem-to-install-fastlane – Florentin Jul 18 '23 at 09:23
1

I think Greg Anderson's solution: https://stackoverflow.com/a/76213903/10917762 is the way to go as it fixes the issue permanently and will not overwrite the fix once you run pod install.

However for me a simple brew upgrade cocoapods did not work so I had to run:

gem cleanup
brew uninstall cocoapods
sudo gem uninstall cocoapods
sudo gem install cocoapods -n /usr/local/bin
sudo gem install cocoapods-user-defined-build-types
pod install --repo-update # run this in your XCode project

The solution is from: https://stackoverflow.com/a/73403613/10917762

Florentin
  • 81
  • 1
  • 2
-2

This problem seems to be recent and the solution that worked really well for me was to go back to Xcode 14.2.

LW001
  • 2,452
  • 6
  • 27
  • 36
Matancy
  • 429
  • 4
  • 5
  • 3
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 16 '23 at 13:54