8

i am maintaining a capacitor ionic project supporting both iOS and android platform. I can build the project locally and run it on a device without any issue. But when archiving the following error pops up:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks 
/Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/IntermediateBuildFilesPath/App.build/Release-
iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh (in target 
'App' from project 'App')     cd 
/Users/fabus/Development/showmaker/showmaker_festivals/ios/App     
/bin/sh -c /Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/IntermediateBuildFilesPath/App.build/Release-
iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh
mkdir -p /Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/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/Cap
acitor.framework" 
"/Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/InstallationBuildProductsLocation/Applications/App.app/F
rameworks" building file list ... rsync: link_stat 
"/Users/fabus/Development/showmaker/showmaker_festivals/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/97f6331a-ba75-11ed-
a4bc-
863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(
996) [sender=2.6.9] Command PhaseScriptExecution failed with a 
nonzero exit code

I am using following pods:

  pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'

  pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'

  pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'

  pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser'

  pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'

  pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'

  pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network'

  pod 'CapacitorPushNotifications', :path => '../../node_modules/@capacitor/push-notifications'

  pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'

  pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'

  pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'

  pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'

I already desintegrated/updated pods in my ios folder. Cleaned the Build folder shift-command-k. Further there's no special chars or whitespaces in my project name and I did renew all my certificates / load them into xcode. Restarting machine does not solve it either.

What I did as well, was checking the option "For install build only" in my Build phases (Targets > App > Build phases) as suggested here

I haven't touched my build files (capacitor.config, package.json, ...) lately

Update:

Executing the command by hand produces following ouput:

/Users/fabus/Library/Developer/Xcode/DerivedData/App-gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh: line 2: /Target Support Files/Pods-App/Pods-App-frameworks.sh: No such file or directory
Fabus
  • 83
  • 2
  • 6

5 Answers5

50

It seems like there is an issue on Xcode 14.3 and higher. There are open issues on iOS developer forum.

ref: https://developer.apple.com/forums/thread/725230?answerId=746897022#746897022

An idea could be to downgrade to 14.2 and see if it works.

Another workaround without downgrading: Open project in Xcode. Go to Pods -> Target Support Files -> Pods-App-Frameworks and change line 44 to below (basically adding -f in existing code):

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

New Solution: update cocoapods version to the latest one and it should resolve automatically.

Roshan Khadka
  • 519
  • 1
  • 4
  • 6
  • 1
    Indeed! I downgraded to 14.2 - clean install it just works!!! Thank you very much, you saved my day!!! – Fabus Apr 04 '23 at 20:30
  • Nice solution. Can you explain why we need to force (add the -f flag) ? – Thomas Mary Apr 07 '23 at 15:00
  • 1
    @thomasmary in this context, the -f flag stands for "canonicalize." It is used to get the absolute path of the specified file or directory, resolving all symbolic links and relative paths. So line 44 sets the source variable to the absolute path of the file or directory it originally pointed to, resolving any symbolic links and relative paths in the process. – Roshan Khadka Apr 08 '23 at 17:26
  • 2
    Thank you! The Pods-app-frameworks -f fix works well on Xcode 14.3 for IDE builds and ipa archiving with the `xcodebuild` CLI. The error showed up as "cocoapods DVTCoreDeviceEnabledState" when building an ionic capacitor app from command line. – Tom McLellan Apr 12 '23 at 03:48
  • your other work around work for me and thanks a lot I was stuck with that for 2 days – Jeremy Vandermeersch Apr 14 '23 at 07:44
  • Worked for me 14.3 – otman soulimani May 11 '23 at 19:13
  • Couldn't find the option you describe in xcode, on the other hand as stated in the link you provided there is a file that is way easier to find in `APPNAME/ios/App/Pods/Target Support Files/Pods-YOURAPP/Pods-YOURAPP-frameworks.sh`. – cglacet May 25 '23 at 02:04
  • I have also the same issue – Vepa Sabyrow May 25 '23 at 17:08
  • I have edited and updated the answer. – Roshan Khadka Jun 16 '23 at 16:55
  • This should be the accepted answer. Updating Cocoapods did not fix anything for me. – dinesharjani Jun 29 '23 at 10:15
  • Updating to the latest version of cocoapods didn't fix this issue for me either, but doing source="$(readlink -f "${source}")" in my Pods -> Target Support Files -> Pods-[your app name]-Frameworks.sh did fix it! Thank you! – Jane Liu Jul 30 '23 at 19:55
18

Update cocoapods to 1.12.1 which has the fix.

gem update cocoapods, or bundle update cocopods if using bundle, or brew upgrade cocoapods if installed with brew.

themenace
  • 2,601
  • 2
  • 20
  • 33
samwize
  • 25,675
  • 15
  • 141
  • 186
  • 1
    This is the better answer because it persists even after removing the `Pods` directory and reinstalling afresh (e.g. on a new machine). – thehale May 12 '23 at 03:36
  • @thehale as you could see from the date when I answered, cocoapods didn't have a fix with an update yet. – Roshan Khadka May 18 '23 at 17:07
  • @RoshanKhadka Your answer was an effective solution for an urgent need. Now that cocoapods does have a fix, however, this answer now provides the more durable -- and therefore better -- solution to the problem. – thehale May 19 '23 at 06:24
  • @thehale of course, agreed! – Roshan Khadka May 22 '23 at 14:28
  • indeed, I switched the checkmark. Thanks guys! – Fabus May 31 '23 at 12:14
2

Find the file Pods-App-Fremeworks.sh and change the code:

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

for this: (add the -f options after r

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

It's worked for me. I hope to help you.

2

Once you do the below change:

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

We need to do this steps to make it work:

  1. Do Pods deintegrate and integrate back.
  2. Clear build folder & derived data in xCode.
  3. Try to Build or Archive again.
kiran kumar
  • 173
  • 1
  • 6
1

Type echo "Symlinked..." in Xcode search.

Add -f after readlink

Or replace source="$(readlink "${source}")" with source="$(readlink -f "${source}")"

It's working fine for me.

Abhay Singh
  • 1,595
  • 1
  • 23
  • 40