我正在尝试使用post install hook将$(PLATFORM_DIR)/ Developer / Library / Frameworks路径添加到Specta目标Header搜索路径.这显然不是至关重要的,但每次我进行“pod update”时手动添加此路径真的很烦人.
我得到了以下脚本:
post_install do |installer_representation| installer_representation.project.targets.each do |target| if target.name == 'Specta' target.build_configurations.each do |config| headers = config.build_settings['HEADER_SEARCH_PATHS'] if headers config.build_settings['HEADER_SEARCH_PATHS'] += ' $(PLATFORM_DIR)/Developer/Library/Frameworks' end end end end end
如果有人能指出我正确的方向,我会很高兴,因为我真的被卡住了.
附:我已经注意到这条路径已经被CocoaPods添加了,但我仍然对如何做到这一点非常感兴趣,因为这些知识以后会很有用.谢谢!
解决方法
在Podfile中定义一个方法:
def append_header_search_path(target,path) target.build_configurations.each do |config| # Note that there's a space character after `$(inherited)`. config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) " config.build_settings["HEADER_SEARCH_PATHS"] << path end end
installer.pods_project.targets.each do |target| if target.name == "Specta" append_header_search_path(target,"$(PLATFORM_DIR)/Developer/Library/Frameworks") end end