class Pod::Sandbox::HeadersStore
Constants
- SYMLINK_REFERENCE
Implememt the effect of tuples.
Attributes
Indicates whether this target uses a custom mapping file
Public Instance Methods
Recording the mapping information between namesapce along with header file and it's path.
# File lib/cocoapods-headermap/headers_store.rb, line 44 def add_files(namespace, relative_header_paths) root.join(namespace).mkpath unless relative_header_paths.empty? new_add_files(namespace, relative_header_paths) if Configuration.keep_symlink_reference return if @visibility_scope == :public list = namespace.each_filename.to_a parts = purge_shared_keys(list, 0) relative_header_paths.map do |relative_header_path| add_targets_headers(parts, relative_header_path) add_project_headers(relative_header_path) end # If the user provides his own modulemap file, keeping the soft link to # avoid being unable to find the umbrella header file. # # `SVGKit` and 'SDWebImageWebPCoder' fits this situation since they has theirs own modulemap file. new_add_files(namespace, relative_header_paths) if !Configuration.keep_symlink_reference && user_clang_module end
Maintain the mapping between the name of header file and its path. It has the following structure:
{ "AFNetworking" => "$PODS_ROOT/AFNetworking/AFNetworking.h", "SDWebImage" => "$PODS_ROOT/SDWebImage/SDWebImage/Core/SDWebImage.h" }
It will be used in `USER_HEADER_SEARCH_PATH` finally, that means you can only use quote to import un-namespaced header files rather than angle brackets.
I did this on purpose to avoid the header file with the same name as the system being written into the hmap file. And this will cause import wrong header file if using brackets. For example, `#import <sqlite3>` in `YYKVStorage` import the file `sqlite3.h` in `WCDBOptimizedSQLCipher` for mistake.
# File lib/cocoapods-headermap/headers_store.rb, line 102 def add_project_headers(relative_header_path) header_source = (sandbox.root + relative_header_path) source_file_name = header_source.basename.to_s header_section = { "prefix" => "#{header_source.dirname.to_s}/", "suffix" => source_file_name.to_s } return if pod_project_headers.key?(source_file_name) && (pod_project_headers[source_file_name]["prefix"] <=> "#{header_source.dirname.to_s}/") == 1 pod_project_headers[source_file_name] = header_section end
Maintain the mapping between the namespace along with header file's name and its path. It has the following structure:
{ "AFNetworking/AFNetworking.h" => "$PODS_ROOT/AFNetworking/AFNetworking.h", "SDWebImage/SDWebImage.h" => "$PODS_ROOT/SDWebImage/SDWebImage/Core/SDWebImage.h" }
It will be used in `HEADER_SEARCH_PATH` finally, you can either use double quotes or angle brackets to import header files.
Following header file that has the same name with previous one will override the existing key If the lexicographic order of the path is greater than the previous one. It is the default behavior same as CocoaPods does.
# File lib/cocoapods-headermap/headers_store.rb, line 76 def add_targets_headers(parts, relative_header_path) header_source = (sandbox.root + relative_header_path) header_section = { "prefix" => "#{header_source.dirname.to_s}/", "suffix" => header_source.basename.to_s } parts.each do |part| key = "#{part}/#{header_source.basename}" next if pod_target_headers.key?(key) && (pod_target_headers[key]["prefix"] <=> "#{header_source.dirname.to_s}/") == 1 pod_target_headers[key] = header_section end end
@return [Hash{Pathname => Hash{String, String}}] The headers mapping for gererating project hmap file.
# File lib/cocoapods-headermap/headers_store.rb, line 28 def pod_project_headers @pod_project_headers ||= {} end
@return [Hash{Pathname => Hash{String, String}}] The headers mapping for gererating all target hmap file.
# File lib/cocoapods-headermap/headers_store.rb, line 23 def pod_target_headers @pod_target_headers ||= {} end
Clean `$PODS_ROOT/Headers` directory.
# File lib/cocoapods-headermap/headers_store.rb, line 125 def rm_headers_root! return if @visibility_scope == :private FileUtils.rm_rf(Dir.glob(sandbox.headers_root + "*.hmap")) end
@return [Array<String>] The path of `hmap` file for all targets. If `keep_symlink_reference` is enabled, it will concat the search paths of the header directory.
# File lib/cocoapods-headermap/headers_store.rb, line 116 def search_paths(platform, target_name = nil, use_modular_headers = false) headers_dir = root.relative_path_from(sandbox.root).dirname paths = ["${PODS_ROOT}/#{headers_dir}/#{Sandbox::POD_TARGETS_HEADERS}.hmap"] paths.concat(new_search_paths(platform, target_name, use_modular_headers)) if Configuration.keep_symlink_reference paths end
# File lib/cocoapods-headermap/headers_store.rb, line 18 def user_clang_module=(user_clang_module) @user_clang_module = user_clang_module end