Upgrade from xCode 14.2 to 14.3 PhaseScriptExecution failed with a nonzero exit code

Hello,

I've upgraded from xcode 14.2 to xcode 14.3 beta, and now I can't archive anymore for Any iOS Device (arm64) with the following error :

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks

mkdir -p /Users/max/Library/Developer/Xcode/DerivedData/Max-dmwafkgdrzqavzcmbdjbjgmmuxby/Build/Intermediates.noindex/ArchiveIntermediates/Release_preprod/BuildProductsPath/Release_preprod-iphoneos/MaxApp.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/ActionSheetPicker_3_0.framework" "/Users/max/Library/Developer/Xcode/DerivedData/Max-dmwafkgdrzqavzcmbdjbjgmmuxby/Build/Intermediates.noindex/ArchiveIntermediates/Release_preprod/InstallationBuildProductsLocation/Applications/MaxApp.app/Frameworks"

building file list ... rsync: link_stat "/Users/max/Workspace/MaxApp/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/ActionSheetPicker_3_0.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

Any idea why it works fine with xCode 14.2 and not with xCode 14.3 beta please ?

I tryed to delete the [CP] Embed Pods Frameworks script, but it has re-created it and get the same issue.

I tryed to build and debug in a simulator, and it works fine.

I tryed to delete "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; in the .pbxproj file

Answered by vadimwe in 749297022

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

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

with

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

Seems this is CocoaPods issue...

The solution of @vadimwe didn't work for me. Still getting error build: Command PhaseScriptExecution failed with a nonzero exit code under RealmJS pod.

I encountered a similar problem, and I found @vadimwe's solution to be effective. I greatly appreciate this. It's important to ensure that you update CocoaPods before implementing @vadimwe's solution.

Thanks @AfsalMe

I just had to update my pod version to the 1.12.1 version through the following code:

sudo gem install cocoapods

@vadimwe thanks !

I have added the flag -f and also downgraded to Xcode 12, but still the issue exists. @vadimwe solutions worked for most, but thst still didn't fix my issue. Is there any other workaround. `

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/hclabs/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/plutomobile/IntermediateBuildFilesPath/plutomobile.build/Release-iphoneos/plutomobile.build/Script-44280D450D5E221B6620F3A5.sh (in target 'plutomobile' from project 'plutomobile') cd /Users/hclabs/Downloads/pluto-mobile/ios /bin/sh -c /Users/hclabs/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/plutomobile/IntermediateBuildFilesPath/plutomobile.build/Release-iphoneos/plutomobile.build/Script-44280D450D5E221B6620F3A5.sh


this is the error that comes after I try to take an archive build. I could run the app on the simulator, this issue is only while taking build.

Update cocoapods to the latest version, then run Product -> Clean Build Folder and archive again. This should fix your issue.

Was facing the same issue. @vadimwe Thanks a lot for the solution

Thanks to @vadimwe , I wrote this script as part of my CI/CD process of building with XCode.

find . -type f -name '*-frameworks.sh' -print0 | while IFS= read -r -d '' file; do echo "Found file: $file" sed -i.bak 's/source="$(readlink ("${source}"))"/source="$(readlink -f "${source}")"/g' "$file" done

I was also getting the "PhaseScriptExecution" build error. However, the issue for me was a bad .env file. I was cleaning my keyboard and apparently i saved a bunch of random chars in the env file. Hope this helps someone! (I did the -f fix in the -frameworks.sh file first, but that didn't work). Cheers and ABC - always be coding

Indeed that was a simple fix for Xcode 14.3.1 for me however, building the same up on Xcode 15 the NXAuth2Client doesn't work and states that there is a double declaration of the method

/APP-PATH/Pods/NXOAuth2Client/Sources/OAuth2Client/NXOAuth2PostBodyPart.m:46:148 Multiple methods named 'contentType' found with mismatched result, parameter type or attributes

@vadimwe I don't find Pods-${app name}-framework.sh in project. Instead I only have Pods-${app name}-resources.sh. But the given line not present in the resource.sh file. How can I resolve this?

In the following solution, what is "APPNAME"? APPNAME/ios/App/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh replaced source="$(readlink "${source}")" with source="$(readlink -f "${source}")"

In case if you are still not able to figure it out, here is the code to add to your Podfile:

valid_target_names = ['Pods-APPNAME']
post_install do |installer|
  installer.pods_project.targets.each do |target|
    modify_file_for_target(target, valid_target_names)
  end
end

def modify_file_for_target(target, valid_target_names)
  target_name = target.name

  if valid_target_names.include?(target_name)
    puts "Target name: #{target_name}"
    file_path = "Pods/Target Support Files/#{target_name}/#{target_name}-frameworks.sh"
    puts "Target file path: #{file_path}"

    text_to_find = 'source="$(readlink "${source}")"'
    replacement_text = 'source="$(readlink -f "${source}")"'

    if File.file?(file_path)
      puts "Modifying file: #{file_path}"

      file_content = File.read(file_path)
      modified_content = file_content.gsub(text_to_find, replacement_text)

      File.open(file_path, 'w') do |file|
        file.puts(modified_content)
      end

      puts "Modification complete."
    else
      puts "Error: File not found - #{file_path}"
    end
  else
    #puts "No change required for target: #{target_name}"
  end
end
Upgrade from xCode 14.2 to 14.3 PhaseScriptExecution failed with a nonzero exit code
 
 
Q