cocoapods-binary icon indicating copy to clipboard operation
cocoapods-binary copied to clipboard

Errors using CocoaPod 1.10.x

Open lzzhang75 opened this issue 4 years ago • 9 comments

Got an error when trying CocoaPod 1.10.x-beta https://github.com/CocoaPods/CocoaPods/issues/10003

Here are the details. Would this be fixed to support CocoaPod 1.10.x?

Report

What did you do?

  • Install v1.10.0.beta.2
  • Add "Pre-compiling" depdency "pod 'CocoaLumberjack/Swift', '~> 3.6', :binary => true"
  • Run pod install

What did you expect to happen?

I expecte the xcode project can compile after the pod install

What happened instead?

Error: Command PhaseScriptExecution failed with nonzero exit code.

Run custom shell script '[CP] Copy dSYMs'

rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/....../Library/Developer/Xcode/DerivedData/......../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/CocoaLumberjack.build/DerivedSources/CocoaLumberjack.framework.framework.dSYM" "/Users/....../Library/Developer/Xcode/DerivedData/....../Build/Products/Debug-iphonesimulator/CocoaLumberjack"
building file list ... rsync: link_stat "/Users/....../Library/Developer/Xcode/DerivedData/....../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/CocoaLumberjack.build/DerivedSources/CocoaLumberjack.framework.dSYM" failed: No such file or directory (2)

CocoaPods Environment

Stack

   CocoaPods : 1.10.0.beta.2
        Ruby : ruby 2.4.6p354 (2019-04-01 revision 67394) [x86_64-darwin18]
    RubyGems : 3.0.6
        Host : Mac OS X 10.15.6 (19G2021)
       Xcode : 11.6 (11E708)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /Users/....../.rvm/rubies/ruby-2.4.6/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /Users/....../.rvm/gems/ruby-2.4.6/bin/pod

Plugins

claide-plugins        : 0.9.2
cocoapods-binary      : 0.4.4
cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0

Podfile

plugin 'cocoapods-binary'

platform :ios, '11.0'
use_frameworks!

AFNETWORKING_VERSION ||= '~> 3.1'

target 'UICollectionView' do
  pod 'AFNetworking/NSURLSession',         AFNETWORKING_VERSION, :binary => true
  pod 'AFNetworking/Reachability',         AFNETWORKING_VERSION, :binary => true
  pod 'AFNetworking/Serialization',        AFNETWORKING_VERSION, :binary => true
  pod 'CocoaLumberjack/Swift',             '~> 3.6', :binary => true
  pod 'Alamofire', '~> 5.2', :binary => true
end

Project that demonstrates the issue

unrelated

Additional Mote

v1.10.x added a build script "CocoaLumberjack-copy-dsyms.sh" when Precompiling is enabled. This script causes build error, as mentioned in the previous sections.

This new script wasn't in v1.9.3 when Precomiling was enabled using v1.9.3

lzzhang75 avatar Aug 24 '20 18:08 lzzhang75

I had the same problem. The script that copies dsym files copies symlinks as symlinks(rsync -av). But since dysm files that are created by cocoapods-binary are symlink files. So changing copy script to 'copy actual files not symlinks' resolves the problem. I don't have much experience on ruby and cocoapods but I come up with the following script.

Add this script to end of your Podfile. Then delete your Pods folder and run pod install again

post_integrate do |installer|
  installer.pods_project.targets.each do |target|
    target.shell_script_build_phases.each do |phase|
      script = phase.shell_script
      if script.include? "-copy-dsyms.sh\""
        script = script.delete_prefix "\"${PODS_ROOT}/"
        script = script.delete_suffix "\"\n"
        script = "Pods/" + script

        contents = File.read(script)
        contents = contents.gsub(/-av/, "-r -L -p -t -g -o -D -v")
        File.open(script, "w") do |file|
          file.puts contents
        end
      end
    end
  end
end

mstfy avatar Sep 06 '20 00:09 mstfy

Thanks @mstfy that seems to be working for me as well.

lzzhang75 avatar Sep 06 '20 02:09 lzzhang75

I'm hitting this too. Thanks @mstfy for figuring out what went wrong.

I wonder what desired fix would be, what do you think @leavez ?

zintus avatar Sep 16 '20 12:09 zintus

The fix above doesn't work for us 😞 We're stuck on v1.9.3. for several months now for this reason 🙈 Did anyone find other workarounds?

rogerluan avatar Jan 17 '21 00:01 rogerluan

@rogerluan in case you have ruby 2.4.10 and get Undefined method delete_prefix for <String...>

https://www.bountysource.com/issues/48195031-string-delete_prefix-is-documented-for-2-4-1-but-does-not-exist-until-2-5-0dev

It's maybe not the optimal way to fix this, but it fixes the error on our end

#          script = script.delete_prefix "\"${PODS_ROOT}/"
#          script = script.delete_suffix "\"\n"
          #https://stackoverflow.com/a/30322598/6060623
          script = script.reverse.chomp("\"${PODS_ROOT}/".reverse).reverse
          script = script.chomp "\"\n"

BUT, a proper workaround would be better

cnadeau avatar Feb 08 '21 00:02 cnadeau

Nope, we use Ruby 2.6.5~2.7.0 - thanks for the suggestion anyway though! @cnadeau

rogerluan avatar Feb 08 '21 20:02 rogerluan

Thanks @mstfy for the script, the only one that worked for me. But in my case, it's a mix of this script and rm -rf ~/Library/Developer/Xcode/DerivedData and remove the pod + install the pod again... And also checking the pods, because some, like Firebase don't work for me with :binary => true

carlosmellado avatar Feb 24 '21 09:02 carlosmellado

I am getting the same error on my Azure pipeline. Nevermind, after clean build locally, it crashes too at the same place.

The following build commands failed: PhaseScriptExecution [CP]\ Copy\ dSYMs

mag2007 avatar Mar 08 '21 08:03 mag2007

use cocoapods-binary in

  • ruby 2.6.8p205
  • cocoapods 1.11.2
  • Xcode13.1 in MacOS 12.0.1

thanks, @mstfy, I change it for the following codes,it works for me

def change_copy_dsyms(installer)
  installer.generated_projects.each do |project|
      project.targets.each do |target|
        target.shell_script_build_phases.each do |phase|
          script = phase.shell_script
          if script.include? "-copy-dsyms.sh\""
              script = script.delete_prefix "\"${PODS_ROOT}/"
              script = script.delete_suffix "\"\n"
            script = "Pods/" + script
            contents = File.read(script)
            contents = contents.gsub(/-av/, "-r -L -p -t -g -o -D -v")
            File.open(script, "w") do |file|
              file.puts contents
            end
          end
        end
      end
  end
end

post_integrate do |installer|
  change_copy_dsyms(installer)
end

kingnight avatar Nov 06 '21 04:11 kingnight