Xcode 12でCarthageが使えなくなって、CocoaPods + cocoapods-binary の構成に移行した方は多いのではないかと思います。僕もそのうちのひとりです。
CocoaPodsはCIサービスでリリースビルド(ipaファイルをエクスポート)する際には毎回フルビルドされます。そのためビルド時間が伸びる傾向にあります。
cocoapods-binaryを使うことで事前にプリビルドしておき、CIサービスでのビルド時間を短縮することができます。cocoapods-binary については、以前エントリを書いたのでよければご覧ください。
CocoaPods v1.10にアップデートするとビルドエラーが発生する
本日 CocoaPods v1.10がリリースされたのでアップデートして、cocoapods-binaryを使っているプロジェクトをビルドしたところ下記のようなエラーが発生しました。
sent 201 bytes received 26 bytes 454.00 bytes/sec total size is 85 speedup is 0.37 rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/ch3cooh/Library/Developer/Xcode/DerivedData/MediaCropper-fxsikdwktzbzvbfokxppfrwokuwk/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/UIDeviceIdentifier.build/DerivedSources/UIDeviceIdentifier.framework.framework.dSYM" "/Users/ch3cooh/Library/Developer/Xcode/DerivedData/MediaCropper-fxsikdwktzbzvbfokxppfrwokuwk/Build/Products/Debug-iphonesimulator/UIDeviceIdentifier" building file list ... rsync: link_stat "/Users/ch3cooh/Library/Developer/Xcode/DerivedData/MediaCropper-fxsikdwktzbzvbfokxppfrwokuwk/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/UIDeviceIdentifier.build/DerivedSources/UIDeviceIdentifier.framework.dSYM" 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/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54.120.1/rsync/main.c(996) [sender=2.6.9] Command PhaseScriptExecution failed with a nonzero exit code
解決策
Podfileに「Errors using CocoaPod 1.10.x · Issue #132 · leavez/cocoapods-binary · GitHub」で紹介されているスクリプトを追加します。Podsディレクトリを削除してから pod update
すれば、いままで通りビルドが通るようになります。
手元のプロジェクトのPodfileは以下のようになりました。
plugin 'cocoapods-binary' # Uncomment the next line to define a global platform for your project # source 'https://cdn.cocoapods.org/' platform :ios, '13.0' enable_bitcode_for_prebuilt_frameworks! keep_source_code_for_prebuilt_frameworks! target 'MediaCropper' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! inhibit_all_warnings! # Pods for MediaCropper pod 'R.swift', :binary => true pod 'LicensePlist', :binary => true pod 'UIDeviceIdentifier', :binary => true pod 'Dollar', :binary => true target 'MediaCropperUITests' do # Pods for testing end end # 追加する 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
Xcode 12のリリースから1ヶ月経ってさまざまなノウハウが共有されてくるようになりました。おかげで僕はXcode 12でCarthageを使えるようになりました。もしお困りの方がいればこちらの記事も合わせていかがでしょうか。
cocoapods-binaryはしばらくメンテナンスされていませんでしたが、Xcode 12でCarthageが使えなくなり cocoapods-binaryを使うユーザーが増えたからか、久しぶりにプロダクトに手が入り始めました。この問題もいずれ解決されると思います。
実行環境
- Xcode 12.1
- CocoaPods v1.10
- cocoapods-binary 0.4.4