Xcode 14.3 cocoapod 1.12.0 packaging error resolution

Preface

A few days ago, I upgraded Xcode to version 14.3 and got an error when running the project, so I recorded it.

development environment

macOS: 13.3.1
Xcode: 14.3
CocoaPods: 1.12.0

Problem Description

[Xcode menu bar] -> [Product] -> [Archive], perform packaging operations. An error is reported when the execution is completed Run custom shell script '[CP] Embed Pods Frameworks'. The error related logs are as follows:

Symlinked...

rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/xxx.framework" "/Users/xxx/Library/Developer/Xcode/DerivedData/app-dukdzczlzijlklamofogqicmtktj/Build/Intermediates.noindex/ArchiveIntermediates/app/InstallationBuildProductsLocation/Applications/app.app/Frameworks"

building file list ... rsync: link_stat "xxx/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/xxx.framework" failed: No such file or directory(2)

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

As shown in the picture:
Error screenshot
Searching on the Internet found a solution: saying that this is a cocoapods problem: https://developer.apple.com/forums/thread/727525 and https://github.com/CocoaPods/CocoaPods/pull/11828 #issuecomment-1497329930
What needs to be modified is to enter the " Pods-APPNAME-frameworks.sh" file of the pod file:

Original code:

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

Change to:

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

This does work, but every time pod installafter executing the command, Pods-app-frameworks.shthe file contents are restored to their original state.



solution

Solution 1: Upgrade CocoaPods version

This is a method I personally recommend, but it may not be available for the time being. The problem will be fixed in version 1.12.1. If you encounter this problem when the CocoaPods version has been released to 1.12.1 or higher, it is recommended to solve the problem by upgrading to the latest version.

Option 2: Modify Podfilethe file

Add this code:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    shell_script_path = "Pods/Target Support Files/#{target.name}/#{target.name}-frameworks.sh"
    if File::exists?(shell_script_path)
      shell_script_input_lines = File.readlines(shell_script_path)
      shell_script_output_lines = shell_script_input_lines.map {
    
     |line| line.sub("source=\"$(readlink \"${source}\")\"", "source=\"$(readlink -f \"${source}\")\"") }
      File.open(shell_script_path, 'w') do |f|
        shell_script_output_lines.each do |line|
          f.write line
        end
      end
    end
  end
end

Re-execute pod installthe command to solve the problem.

Option 3: Modify embed_frameworks_script.rbthe file

The file is located in the path under the CocoaPods package lib/cocoapods/generator/embed_frameworks_script.rb. source="$(readlink "${source}")"Replace the file with source="$(readlink -f "${source}")"and re-execute pod installthe command to solve the problem.

Guess you like

Origin blog.csdn.net/biyuhuaping/article/details/130195913