[!] An error occurred while processing the post-install hook of the Podfile.
/Users/yqs/Documents/justbonAJB/justbon/Podfile:106:in `block (4 levels) in from_ruby'
在Podfile中執(zhí)行到"target.headers_build_phase.clear"的時(shí)候崩潰的問(wèn)題
project.targets.each do |target|
target.headers_build_phase.clear
end
問(wèn)題分析:
在新的xcode版本中pods
image.png
分為開(kāi)源的第三方庫(kù)和閉源的第三方庫(kù),紅色圓圈圖標(biāo)的是閉源庫(kù)铃肯;灰色圖標(biāo)的是開(kāi)源的患亿。區(qū)別在于
Build Phases
里面是否存在Compile Sources
和Headers
。如果沒(méi)有
Headers
執(zhí)行target.headers_build_phase.clear
這句代碼就會(huì)崩潰。
解決辦法1:也是比較直接暴力的方法
project.targets.each do |target|
# .a 文件不需要 copy header
myTargets = ['ActionSheetPicker-3.0','AFNetworking','AliyunOSSiOS']
if myTargets.include? target.name
target.headers_build_phase.clear
end
end
這里先找到存在Headers
的taeget步藕,放入myTargets中惦界,判斷項(xiàng)目中的target是否存在Header
存在就執(zhí)行,不存在就不執(zhí)行咙冗。
解決辦法2:
project.targets.each do |target|
# .a 文件不需要 copy header
# target.headers_build_phase.clear
if target.build_phases.count > 0
target.headers_build_phase.clear
end
end
target.build_phases
會(huì)返回一個(gè)列表沾歪。當(dāng)是開(kāi)源的庫(kù)會(huì)展示這三個(gè)[HeadersBuildPhase, SourcesBuildPhase, FrameworksBuildPhase]
;當(dāng)時(shí)閉源的庫(kù)則數(shù)組為空雾消。
粗淺的認(rèn)識(shí)灾搏,希望可以幫到遇到類(lèi)似問(wèn)題的朋友。就上述有什么不懂的可以咨詢我立润。