leavez / cocoapods-binary

integrate pods in form of prebuilt frameworks conveniently, reducing compile time
MIT License
1.31k stars 206 forks source link

Errors using CocoaPod 1.10.x #132

Open lzzhang75 opened 4 years ago

lzzhang75 commented 4 years ago

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?

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

mstfy commented 4 years ago

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
lzzhang75 commented 4 years ago

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

zintus commented 4 years ago

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 ?

rogerluan commented 3 years ago

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?

cnadeau commented 3 years ago

@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

rogerluan commented 3 years ago

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

carlosmellado commented 3 years ago

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

mag2007 commented 3 years ago

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

kingnight commented 2 years ago

use cocoapods-binary in

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