[!] 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中执行到"target.headers_build_phase.clear"的时候崩溃的问题
project.targets.each do |target|
target.headers_build_phase.clear
end
问题分析:
在新的xcode版本中pods
分为开源的第三方库和闭源的第三方库,红色圆圈图标的是闭源库;灰色图标的是开源的。区别在于
Build Phases
里面是否存在Compile Sources
和Headers
。如果没有
Headers
执行target.headers_build_phase.clear
这句代码就会崩溃。
解决办法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中,判断项目中的target是否存在Header
存在就执行,不存在就不执行。
解决办法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
会返回一个列表。当是开源的库会展示这三个[HeadersBuildPhase, SourcesBuildPhase, FrameworksBuildPhase]
;当时闭源的库则数组为空。
粗浅的认识,希望可以帮到遇到类似问题的朋友。就上述有什么不懂的可以咨询我。