├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── README_en.md ├── Rakefile ├── cocoapods-project-hmap.gemspec └── lib ├── cocoapods-project-hmap.rb ├── cocoapods-project-hmap ├── gem_version.rb ├── hmap_generator.rb ├── pod_target.rb ├── podfile_dsl.rb ├── post_install_hook_context.rb └── xcconfig.rb └── cocoapods_plugin.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | pkg 3 | .idea/ 4 | *.gem 5 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in cocoapods-project-hmap.gemspec 4 | gemspec 5 | 6 | group :development do 7 | gem 'cocoapods' 8 | 9 | gem 'mocha' 10 | gem 'bacon' 11 | gem 'mocha-on-bacon' 12 | gem 'prettybacon' 13 | end 14 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 chenxGen 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cocoapods-project-hmap 2 | 3 | 此插件思路来源于[《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html)。通过使用 header map (以下简称 hmap ) 代替文件路径搜索优化预处理阶段中头文件搜索的性能实现编译速度提升。 4 | 5 | [English Version](./README_en.md) 6 | 7 | ## 首先,什么样的项目适合使用这个插件? 8 | 9 | - **仅适合使用 objective-c 作为主要开发语言项目**,因为 swift 没有头文件的概念,从其编译原理上看并没有什么帮助; 10 | 11 | - **不适合 Podfile 中 开启了 `use_frameworks!` or `use_modular_headers!` 的项目使用**;为了兼容 clang module 特性,采取的策略是不对开启了 DEFINES_MODULE 的项目生成 hmap; 12 | 13 | - **不适用于 CPU 为 M1 以及后续 M 系列芯片的 Mac**;因为使用之后提升也很小; 14 | 15 | 综上,比较适合 old school 的项目使用此插件,如果你的项目满足以上条件推荐使用此插件,不然可能收效甚微,不建议继续往下看了。 16 | 17 | ## 插件名的由来 18 | 19 | 最初版本的插件仅仅为了给 Pod Project 和 Host Project 提供一个可行的跨项目 hmap 方案,填补 Xcode 自带的仅支持 Project 内部的 hmap 的空白,由此得名:cocoapods-project-hmap. 20 | 21 | ## 环境要求 22 | 23 | - CocoaPods Version: `>=1.7.0` 24 | - 安装命令行工具 [hmap](https://github.com/milend/hmap) : `brew install milend/taps/hmap` 25 | 26 | ## 安装 27 | 28 | - 使用Gemfile : 在你的 `Gemfile` 中添加: `gem 'cocoapods-project-hmap'` 29 | - 通过命令行安装 : `sudo gem install cocoapods-project-hmap` 30 | 31 | ## 使用 32 | 33 | 只需要在你的`Podfile`中添加如下行:`plugin 'cocoapods-project-hmap'` 声明使用该插件。 34 | 35 | 同时插件还为`Podfile`提供了一下几个可选的方法调用: 36 | 37 | - **set\_hmap\_black\_pod\_list:** 如果你有第三方库在使用插件后编译失败,可以尝试把它添加到黑名单中 38 | 39 | - **turn\_prebuilt\_hmap\_off\_for\_pod\_targets:** 如果你发现有太多的三方库需要添加到黑名单,你可以直接通过调用这个方法开启“纯净模式”,关闭插件对 Pod Project 内部所有 target 的 header 处理,仅仅对提供给主项目使用的 target 处理 hmap 40 | 41 | - **set\_hmap\_use\_strict\_mode:** 在一个 target 中引用另一个 target 的 header,严格意义上来说应该使用`#import `的方式,但是有些是通过`#import "Header.h"`,这种情况如果设置了对应的 header search path 编译是可以成功的,比如使用原生的 cocoapods 情况下,在项目中使用`#import "Masonry.h"`、`#import `和`#import `三种方式引入都是可以成功的,如果你使用这个插件并且开启这个选项后只有`#import `可以编译成功。默认为关闭。 42 | 43 | 44 | 最终你的Podfile看起来会是这样的 : 45 | 46 | ```ruby 47 | platform :ios, '10.0' 48 | plugin 'cocoapods-project-hmap' 49 | set_hmap_black_pod_list(['PodA','PodB']) 50 | turn_prebuilt_hmap_off_for_pod_targets 51 | #set_hmap_use_strict_mode(true) 52 | 53 | target 'app' do 54 | pod 'PodA' 55 | ... 56 | pod 'PodB' 57 | end 58 | ``` 59 | 60 | ## 联系方式 61 | 62 | QQ: 930565063 63 | 64 | ## License 65 | 66 | cocoapods-project-hmap is released under the MIT license. See LICENSE for details. 67 | -------------------------------------------------------------------------------- /README_en.md: -------------------------------------------------------------------------------- 1 | # cocoapods-project-hmap 2 | 3 | A cocoapods plugin to improve compilation speed at preprosessor phase by using hmap instead of file paths for header searching. The idea comes from [《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html) 4 | 5 | ## First 6 | 7 | What kind of projects are recommended to use this plugin? 8 | 9 | - **Project using objective-c as their main develop language** 10 | - **Project not using `use_frameworks!` and `use_modular_headers!` in their Podfile** 11 | 12 | and Developer not using Mac with M series CPU. 13 | 14 | ## Requirement 15 | 16 | - CocoaPods Version: `>=1.7.0` 17 | - Install command line tool [hmap](https://github.com/milend/hmap) : `brew install milend/taps/hmap` 18 | 19 | ## Installation 20 | 21 | - With Gemfile : Add this line to your `Gemfile` : `gem 'cocoapods-project-hmap'` 22 | - With CommandLine : `sudo gem install cocoapods-project-hmap` 23 | 24 | ## Usage 25 | 26 | In your `Podfile`, add this line : `plugin 'cocoapods-project-hmap'` 27 | 28 | And this plugin also provides Podfile DSL bellow: 29 | 30 | - `set_hmap_black_pod_list`: If you have some compilation error for pod targets because of this plugin, adding the target name to black list... 31 | - `turn_prebuilt_hmap_off_for_pod_targets`: If you have to many build error after using this plugin, or have to add to many 'pod' to black list, I provides a most non-intrusive way to use, call this method `turn_prebuilt_hmap_off_for_pod_targets` to ignore hmap prebuilt for most of the pod target (excepting the 'main' pods, named `Pods-${YOUR SCHEME}`). 32 | - `set_hmap_use_strict_mode`: Import a header in other library(PodA), strictly speaking, we should use `#import `, but not all library developer do like that, if you turn it on, you can find then. 33 | 34 | The code in your Podfile may look like that in the end : 35 | 36 | ```ruby 37 | platform :ios, '10.0' 38 | plugin 'cocoapods-project-hmap' 39 | set_hmap_black_pod_list(['PodA','PodB']) 40 | turn_prebuilt_hmap_off_for_pod_targets 41 | #set_hmap_use_strict_mode(true) 42 | 43 | target 'app' do 44 | pod 'PodA' 45 | ... 46 | pod 'PodB' 47 | end 48 | ``` 49 | 50 | ## Contact 51 | 52 | Your can contact me on [Twitter](http://twitter.com/chenxGen). 53 | 54 | ## License 55 | 56 | cocoapods-project-hmap is released under the MIT license. See LICENSE for details. 57 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | 3 | def specs(dir) 4 | FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ') 5 | end 6 | 7 | desc 'Runs all the specs' 8 | task :specs do 9 | sh "bundle exec bacon #{specs('**')}" 10 | end 11 | 12 | task :default => :specs 13 | 14 | -------------------------------------------------------------------------------- /cocoapods-project-hmap.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'cocoapods-project-hmap/gem_version.rb' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'cocoapods-project-hmap' 8 | spec.version = CocoapodsProjectHmap::VERSION 9 | spec.authors = ['chenxGen'] 10 | spec.email = ['chenxGen@outlook.com'] 11 | spec.description = %q{A cocoapods plugin which using hmap instead of header search paths to improve preprocess time.} 12 | spec.summary = %q{A cocoapods plugin which using hmap instead of header search paths to improve preprocess time.} 13 | spec.homepage = 'https://github.com/chenxGen/cocoapods-project-hmap' 14 | spec.license = 'MIT' 15 | 16 | spec.files = `git ls-files`.split($/) 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ['lib'] 20 | 21 | spec.add_development_dependency 'bundler', '~> 1.3' 22 | spec.add_development_dependency 'rake' 23 | end 24 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-project-hmap/gem_version' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap/gem_version.rb: -------------------------------------------------------------------------------- 1 | module CocoapodsProjectHmap 2 | VERSION = "0.0.6" 3 | end 4 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap/hmap_generator.rb: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env ruby 2 | 3 | module ProjectHeaderMap 4 | class HmapGenerator 5 | QUOTE = 1 # 001 6 | ANGLE_BRACKET = 2 # 010 7 | BOTH = 3 # 011 8 | def initialize 9 | @hmap = Hash.new 10 | end 11 | # header_mapping : [Hash{FileAccessor => Hash}] Hash of file accessors by header mappings. 12 | def add_hmap_with_header_mapping(header_mapping, type, target_name=nil, module_name=nil) 13 | header_mapping.each do |facc, headers| 14 | headers.each do |key, value| 15 | value.each do |path| 16 | pn = Pathname.new(path) 17 | name = pn.basename.to_s 18 | dirname = pn.dirname.to_s + '/' 19 | # construct hmap hash info 20 | path_info = Hash['suffix' => name, 'prefix' => dirname] 21 | if type & QUOTE > 0 22 | # import with quote 23 | @hmap[name] = path_info 24 | end 25 | if type & ANGLE_BRACKET > 0 26 | if target_name != nil 27 | # import with angle bracket 28 | @hmap["#{target_name}/#{name}"] = path_info 29 | end 30 | if module_name != nil && module_name != target_name 31 | @hmap["#{module_name}/#{name}"] = path_info 32 | end 33 | end 34 | end 35 | end 36 | end 37 | end 38 | # @path : path/to/xxx.hmap 39 | # @return : succeed 40 | def save_to(path) 41 | if path != nil && @hmap.empty? == false 42 | pn=Pathname(path) 43 | json_path=pn.dirname.to_s + '/' + 'temp.json' 44 | # write hmap json to file 45 | File.open(json_path, 'w') { |file| file << @hmap.to_json } 46 | # json to hmap 47 | suc=system("hmap convert #{json_path} #{path}") 48 | # delete json file 49 | File.delete(json_path) 50 | suc 51 | else 52 | false 53 | end 54 | end 55 | def empty? 56 | @hmap.empty? 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap/pod_target.rb: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env ruby 2 | require 'cocoapods-project-hmap/xcconfig' 3 | require 'cocoapods-project-hmap/hmap_generator' 4 | require 'cocoapods-project-hmap/podfile_dsl' 5 | 6 | SAVED_HMAP_DIR='prebuilt-hmaps' 7 | 8 | module Pod 9 | class Target 10 | attr_accessor :prebuilt_hmap_target_names 11 | def save_hmap(hmap) 12 | if hmap.empty? == false 13 | target_hmap_name="#{name}.hmap" 14 | relative_hmap_path = "#{SAVED_HMAP_DIR}/#{target_hmap_name}" 15 | target_hmap_path = sandbox.root.to_s + "/#{relative_hmap_path}" 16 | hmaps_dir = sandbox.root.to_s + "/#{SAVED_HMAP_DIR}" 17 | unless File.exist?(hmaps_dir) 18 | Dir.mkdir(hmaps_dir) 19 | end 20 | if hmap.save_to(target_hmap_path) 21 | reset_header_search_with_relative_hmap_path(relative_hmap_path) 22 | end 23 | end 24 | end 25 | def add_prebuilt_hmap_target(name) 26 | @prebuilt_hmap_target_names = Array.new if @prebuilt_hmap_target_names == nil 27 | @prebuilt_hmap_target_names << name 28 | end 29 | def concat_prebuilt_hmap_targets(names) 30 | @prebuilt_hmap_target_names = Array.new if @prebuilt_hmap_target_names == nil 31 | @prebuilt_hmap_target_names.concat(names) if names 32 | end 33 | end 34 | 35 | class PodTarget 36 | def reset_header_search_with_relative_hmap_path(hmap_path) 37 | if build_settings.instance_of?(Hash) 38 | build_settings.each do |config_name, setting| 39 | config_file = setting.xcconfig 40 | config_file.reset_header_search_with_relative_hmap_path(hmap_path, @prebuilt_hmap_target_names.uniq) 41 | # https://github.com/CocoaPods/CocoaPods/issues/1216 42 | # just turn off private xcconfig's USE_HEADERMAP flag 43 | config_file.set_use_hmap(false) 44 | config_path = xcconfig_path(config_name) 45 | config_file.save_as(config_path) 46 | end 47 | elsif build_settings.instance_of?(BuildSettings::PodTargetSettings) 48 | config_file = build_settings.xcconfig 49 | config_file.reset_header_search_with_relative_hmap_path(hmap_path, @prebuilt_hmap_target_names.uniq) 50 | # https://github.com/CocoaPods/CocoaPods/issues/1216 51 | # just turn off private xcconfig's USE_HEADERMAP flag 52 | config_file.set_use_hmap(false) 53 | config_path = xcconfig_path 54 | config_file.save_as(config_path) 55 | else 56 | Pod::UI.notice 'Unknown build settings' 57 | end 58 | end 59 | def recursively_add_dependent_headers_to_hmap(hmap, generate_type) 60 | dependent_targets.each do |depend_target| 61 | # set public header for dependent target 62 | depend_target.generate_hmap(hmap, generate_type, true, true) if depend_target.respond_to?(:generate_hmap) 63 | concat_prebuilt_hmap_targets(depend_target.prebuilt_hmap_target_names) if depend_target.prebuilt_hmap_target_names 64 | end 65 | end 66 | 67 | def generate_hmap(hmap, generate_type, only_public_headers=true, add_dependency=false) 68 | # There is no need to add headers of target defines module to hmap. 69 | unless defines_module? 70 | unless $hmap_black_pod_list.include?(name) 71 | add_prebuilt_hmap_target(name) 72 | # Create hmap for current target if not in black list. 73 | hmap.add_hmap_with_header_mapping(only_public_headers ? public_header_mappings_by_file_accessor : header_mappings_by_file_accessor, generate_type, name, product_module_name) 74 | # Recursively add dependent targets if needed. 75 | recursively_add_dependent_headers_to_hmap(hmap, generate_type) if add_dependency 76 | else 77 | Pod::UI.message "- skip target in black list :#{name}" 78 | end 79 | end 80 | end 81 | end 82 | class AggregateTarget 83 | def reset_header_search_with_relative_hmap_path(hmap_path) 84 | # override xcconfig 85 | xcconfigs.each do |config_name, config_file| 86 | config_file.reset_header_search_with_relative_hmap_path(hmap_path, @prebuilt_hmap_target_names.uniq) 87 | config_path = xcconfig_path(config_name) 88 | config_file.save_as(config_path) 89 | end 90 | end 91 | end 92 | end 93 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap/podfile_dsl.rb: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env ruby 2 | # built-in black list pods 3 | # you can use hmap_black_pod_list to add other pods 4 | $hmap_black_pod_list = [] 5 | 6 | $strict_mode = false 7 | $prebuilt_hmap_for_pod_targets = true 8 | 9 | module Pod 10 | class Podfile 11 | module DSL 12 | def set_hmap_black_pod_list(pods) 13 | if pods != nil && pods.size() > 0 14 | $hmap_black_pod_list.concat(pods) 15 | end 16 | end 17 | # if use strict mode, main project can only use `#import ` 18 | # `#import ` will get 'file not found' error 19 | # as well as PodTarget dependent on other PodTarget 20 | def set_hmap_use_strict_mode 21 | $strict_mode = true 22 | end 23 | # turn off prebuilt hmap for targets in pod project except the `main` target 24 | def turn_prebuilt_hmap_off_for_pod_targets 25 | $prebuilt_hmap_for_pod_targets = false 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap/post_install_hook_context.rb: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env ruby 2 | 3 | module Pod 4 | class Installer 5 | class PostInstallHooksContext 6 | attr_accessor :aggregate_targets 7 | version = Gem::Version.new(Pod::VERSION) 8 | if version < Gem::Version.new('1.7.0') 9 | # Method `generate` has two args 10 | class << self 11 | alias old_generate generate 12 | def generate(sandbox, aggregate_targets) 13 | context = old_generate(sandbox, aggregate_targets) 14 | UI.info "- generate method of post install hook context hooked" 15 | context.aggregate_targets = aggregate_targets 16 | context 17 | end 18 | end 19 | elsif version < Gem::Version.new('1.10.0') 20 | # Method `generate` has three args 21 | class << self 22 | alias old_generate generate 23 | def generate(sandbox, pods_project, aggregate_targets) 24 | context = old_generate(sandbox, pods_project, aggregate_targets) 25 | UI.info "- generate method of post install hook context hooked" 26 | context.aggregate_targets = aggregate_targets 27 | context 28 | end 29 | end 30 | elsif version < Gem::Version.new('1.12.0') 31 | # PostInstallHooksContext inherited from BaseContext, just override `generate` 32 | def self.generate(sandbox, pods_project, aggregate_targets) 33 | context = super 34 | UI.info "- generate method of post install hook context override" 35 | context.aggregate_targets = aggregate_targets 36 | context 37 | end 38 | else 39 | def self.generate(sandbox, pods_project, pod_target_subprojects, aggregate_targets) 40 | context = super 41 | UI.info "- generate method of post install hook context override" 42 | context.aggregate_targets = aggregate_targets 43 | context 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/cocoapods-project-hmap/xcconfig.rb: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env ruby 2 | 3 | module Xcodeproj 4 | class Config 5 | def remove_attr_with_key(key) 6 | unless key == nil 7 | @attributes.delete(key) 8 | end 9 | end 10 | def remove_header_search_path(prebuilt_hmap_target_names=nil) 11 | header_search_paths = @attributes['HEADER_SEARCH_PATHS'] 12 | if header_search_paths 13 | new_paths = Array.new 14 | header_search_paths.split(' ').each do |p| 15 | unless search_path_should_be_deleted?(p, prebuilt_hmap_target_names) 16 | new_paths << p 17 | end 18 | end 19 | if new_paths.size > 0 20 | @attributes['HEADER_SEARCH_PATHS'] = new_paths.join(' ') 21 | else 22 | remove_attr_with_key('HEADER_SEARCH_PATHS') 23 | end 24 | end 25 | remove_system_option_in_other_cflags(prebuilt_hmap_target_names) 26 | end 27 | def search_path_should_be_deleted?(search_path, prebuilt_hmap_target_names=nil) 28 | # Check if the path should be deleted from search list 29 | # 1. It must be at the ${PODS_ROOT} directory 30 | # 2. It has generated hmap 31 | ret = false 32 | if search_path.include?('${PODS_ROOT}/Headers') 33 | if prebuilt_hmap_target_names 34 | ret = prebuilt_hmap_target_names.select { |name| search_path.include?(name) }.empty? == false 35 | end 36 | end 37 | ret 38 | end 39 | def remove_system_option_in_other_cflags(prebuilt_hmap_target_names=nil) 40 | # ---------------------------------------------- 41 | # -I, --include-directory , --include-directory= 42 | # Add directory to include search path. For C++ inputs, if there are multiple -I options, 43 | # these directories are searched in the order they are given before the standard system directories are searched. 44 | # If the same directory is in the SYSTEM include search paths, for example if also specified with -isystem, the -I option will be ignored 45 | # 46 | # -isystem 47 | # Add directory to SYSTEM include search path 48 | # ---------------------------------------------- 49 | flags = @attributes['OTHER_CFLAGS'] 50 | if flags 51 | new_flags = '' 52 | is_isystem_flag = false 53 | flags.split(' ').each do |substr| 54 | append_str = substr 55 | # Previous flag is `isystem` 56 | if is_isystem_flag 57 | is_isystem_flag = false 58 | if search_path_should_be_deleted?(append_str, prebuilt_hmap_target_names) 59 | next 60 | else 61 | # recover 62 | append_str = "-isystem #{append_str}" 63 | end 64 | end 65 | 66 | if append_str == '-isystem' 67 | is_isystem_flag = true 68 | next 69 | end 70 | 71 | if new_flags.length > 0 72 | new_flags += ' ' 73 | end 74 | new_flags += append_str 75 | end 76 | 77 | if new_flags.length > 0 78 | @attributes['OTHER_CFLAGS'] = new_flags 79 | else 80 | remove_attr_with_key('OTHER_CFLAGS') 81 | end 82 | end 83 | end 84 | def reset_header_search_with_relative_hmap_path(hmap_path, prebuilt_hmap_target_names=nil) 85 | # Delete associate search paths 86 | remove_header_search_path(prebuilt_hmap_target_names) 87 | # Add hmap file to search path 88 | new_paths = Array["${PODS_ROOT}/#{hmap_path}"] 89 | header_search_paths = @attributes['HEADER_SEARCH_PATHS'] 90 | if header_search_paths 91 | new_paths.concat(header_search_paths.split(' ')) 92 | end 93 | @attributes['HEADER_SEARCH_PATHS'] = new_paths.join(' ') 94 | end 95 | def set_use_hmap(use=false) 96 | @attributes['USE_HEADERMAP'] = (use ? 'YES' : 'NO') 97 | end 98 | end 99 | end 100 | -------------------------------------------------------------------------------- /lib/cocoapods_plugin.rb: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env ruby 2 | 3 | require 'cocoapods-project-hmap/pod_target' 4 | require 'cocoapods-project-hmap/post_install_hook_context' 5 | 6 | module ProjectHeaderMap 7 | Pod::HooksManager.register('cocoapods-project-hmap', :post_install) do |post_context| 8 | generate_type = $strict_mode ? HmapGenerator::ANGLE_BRACKET : HmapGenerator::BOTH 9 | post_context.aggregate_targets.each do |one| 10 | pods_hmap = HmapGenerator.new 11 | Pod::UI.message "- hanlding headers of aggregate target :#{one.name}" 12 | one.pod_targets.each do |target| 13 | target.generate_hmap(pods_hmap, generate_type, true, false) 14 | target_hmap = HmapGenerator.new 15 | target.generate_hmap(target_hmap, HmapGenerator::BOTH, false, true) 16 | target.save_hmap(target_hmap) 17 | one.concat_prebuilt_hmap_targets(target.prebuilt_hmap_target_names) 18 | end 19 | one.save_hmap(pods_hmap) 20 | end 21 | end 22 | end 23 | --------------------------------------------------------------------------------