Xcode Archive command fails with Ionic Capacitor and React - Command PhaseScriptExecution failed with a nonzero exit code
Asked Answered
G

6

12

For a couple of days, without changing any details on the project, I've been receiving this error during the Xcode publishing phase. I have also shared my code with other developers, and on their computer publishing is not a problem.

Below is the error log:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/[USER_NAME]/Library/Developer/Xcode/DerivedData/App-faqqbffxhfofrrewfezzfuhlylqt/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh (in target 'App' from project 'App')
    cd /Users/[USER_NAME]/Desktop/Workspace/[APP_NAME]/ios/App
    /bin/sh -c /Users/[USER_NAME]/Library/Developer/Xcode/DerivedData/App-faqqbffxhfofrrewfezzfuhlylqt/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh

mkdir -p /Users/[USER_NAME]/Library/Developer/Xcode/DerivedData/App-faqqbffxhfofrrewfezzfuhlylqt/Build/Intermediates.noindex/ArchiveIntermediates/App/BuildProductsPath/Release-iphoneos/App.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/Capacitor.framework" "/Users/[USER_NAME]/Library/Developer/Xcode/DerivedData/App-faqqbffxhfofrrewfezzfuhlylqt/Build/Intermediates.noindex/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App.app/Frameworks"
building file list ... rsync: link_stat "/Users/[USER_NAME]/Desktop/Workspace/[APP_NAME]/ios/App/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Capacitor.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/9e200cfa-7d96-11ed-886f-a23c4f261b56/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code

Tried to reinstall Capacitor, rebuild the pods, the entire ios folder and project. Also uninstalled and reinstalled Xcode. I'm always stuck at the same point.

Gerfalcon answered 31/3, 2023 at 21:42 Comment(2)
Please trim your code to make it easier to find your problem. Follow these guidelines to create a minimal reproducible example.Insignificancy
i was facing same issue not found any solution, i formatting my mac then only workPucida
F
20

The answer provided by Baryon Lee worked for me. However for those who are looking for the place where this change has to be applied, you should go to the following path:

/ios/App/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh

And then replace:

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

with:

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

Flee answered 5/4, 2023 at 13:17 Comment(1)
Perfect workaround!Paint
C
5

https://github.com/CocoaPods/CocoaPods/issues/11808#issuecomment-1480802886

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

This is my first time contributing to CocoaPods though, so take it with a grain of salt!

Cocoon answered 3/4, 2023 at 11:0 Comment(0)
H
3

I use ionic capacitor. I was facing the same issues with MacBook M1 Pro and Xcode 14.3. I downgraded Xcode to 14.2 but it slowed down the build process.

Then I reinstalled 14.3 and replaced:

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

With:

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

And it works. Remember to do this only before doing the Archive.

Homy answered 7/4, 2023 at 10:43 Comment(0)
P
1

Got the same issue, XCode 14.3 is the issue! Downgrade to 14.2 and it will work. https://developer.apple.com/download/all/?q=14.2

Precession answered 3/4, 2023 at 2:7 Comment(1)
I am also facing this only since this morning. XCode 14.3 - I don't want to downgrade yetFootle
E
0

Since changing the generated files are hard, I wrote a post_install script that does the same workaround mentioned above by others. target name depends on your project such as "App".

In your Podfile, (ios/App/Podfile) you can add this.

post_install do |installer|
  installer.aggregate_targets.each do |target|
    if target.name == 'Pods-<Target Name>' # Your target name here
        frameworkPath = "Pods/Target Support Files/#{target.name}/#{target.name}-frameworks.sh"
        puts "Found #{frameworkPath}"
        text = File.read(frameworkPath)
        new_contents = text.gsub('readlink "${source}"', 'readlink -f "${source}"') # Detect and replace the line
        File.open(frameworkPath, "w") {|file| file.puts new_contents}
        puts "Updated #{target.name} framework file for xcode 14.3 cocoapods issue"
    end
  end
end
Ebonize answered 18/4, 2023 at 10:49 Comment(0)
U
0

It is fixed now. Update cocoapods to 1.12.1

https://github.com/ionic-team/capacitor/issues/6457

Unwonted answered 17/5, 2023 at 8:11 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewBergama

© 2022 - 2024 — McMap. All rights reserved.