Xcode10 Archive Error - Multiple command product 'xxx/Info.plist' 解決方案

weixin_33782386發表於2019-01-09

報錯資訊

:-1: Multiple commands produce '/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-cqedfsiaqyswfpdkffoiytinrkcj/Build/Intermediates.noindex/ArchiveIntermediates/XXX/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Info.plist':
1) Target 'XXX' (project 'Pods') has copy command from '/Users/XXX/Documents/SourceCode//XXX/Pods/XXX/XXX/Info.plist' to '/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-cqedfsiaqyswfpdkffoiytinrkcj/Build/Intermediates.noindex/ArchiveIntermediates/XXX/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Info.plist'
2) Target 'XXX' (project 'Pods') has copy command from '/Users/XXX/Documents/SourceCode//XXX/Pods/XXX/XXX/Info.plist' to '/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-cqedfsiaqyswfpdkffoiytinrkcj/Build/Intermediates.noindex/ArchiveIntermediates/XXX/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Info.plist'
3) Target 'XXX' (project 'Pods') has copy command from '/Users/XXX/Documents/SourceCode/XXX/Pods/XXX/XXX/Info.plist' to '/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-cqedfsiaqyswfpdkffoiytinrkcj/Build/Intermediates.noindex/ArchiveIntermediates/XXX/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Info.plist'
4) Target 'XXX' (project 'Pods') has copy command from '/Users/XXX/Documents/SourceCode/XXX/Pods/XXX/XXX/Info.plist' to '/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-cqedfsiaqyswfpdkffoiytinrkcj/Build/Intermediates.noindex/ArchiveIntermediates/XXX/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Info.plist'

原因

Xcode10使用了新的task的build方式,之前在做私有庫的時候沒有很嚴格,將私有庫的Info.plist檔案也放在了Pod-Spec檔案中引入到工程了,所以新的打包方式將這些Info.plist和主工程的都copy到相同的地方發生了報錯。

解決方案

原因知道了那麼解決方案就很清楚--將這些Info.plist從工程中刪除掉:

  1. 修改私有庫的spec檔案,然後升級每一個私有庫。這是最正確的但是有很多時候專案私有庫很多,依賴很複雜,升級一次成本很高。
  2. 既然使用了Pod那就在Pod指令碼上想想辦法,很顯然可有在Podfile的Hook方法,post_install裡面講pod庫的Info.plist引用刪除掉,程式碼如下:
### HOOK POST
post_install do |installer|
    installer.pods_project.native_targets.each do |natviTarget|
        natviTarget.build_phases.each do |buildPhase|
            info_plist_ref = buildPhase.files.find { |f| f.file_ref.to_s == "Info.plist" }
            if info_plist_ref
               buildPhase.remove_reference(info_plist_ref)
            end
        end
    end
end

相關文章