我正在尝试使用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
如果有人能指出我正确的方向,我会很高兴,因为我真的被卡住了。
P.S。我已经注意到这条路径已经被CocoaPods添加了,但我仍然对如何做到这一点非常感兴趣,因为这些知识以后会很有用。谢谢!
答案 0 :(得分:0)
在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
然后在post_install
中调用方法:
installer.pods_project.targets.each do |target|
if target.name == "Specta"
append_header_search_path(target, "$(PLATFORM_DIR)/Developer/Library/Frameworks")
end
end