class Pod::Sandbox::HeadersStore

Constants

Implememt the effect of tuples.

Attributes

user_clang_module[R]

Indicates whether this target uses a custom mapping file

Public Instance Methods

add_files(namespace, relative_header_paths) click to toggle source

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
Also aliased as: new_add_files
add_project_headers(relative_header_path) click to toggle source

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
add_targets_headers(parts, relative_header_path) click to toggle source

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
new_add_files(namespace, relative_header_paths)
Alias for: add_files
new_search_paths(platform, target_name = nil, use_modular_headers = false)
Alias for: search_paths
pod_project_headers() click to toggle source

@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
pod_target_headers() click to toggle source

@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
purge_shared_keys(parts, index) click to toggle source

@return [Array<Pathname>] Generate every part of namespace recusively. Passing [“WCDB”, “include”, “source”] return the following content:

“WCDB/include/source”, “include/source”, “source”
# File lib/cocoapods-headermap/headers_store.rb, line 36
def purge_shared_keys(parts, index)
    return [] if index == parts.length
    res = [parts.slice(index, parts.length - index).reduce(Pathname.new(""), :+)]
    res.concat(purge_shared_keys(parts, index + 1))
    res
end
rm_headers_root!() click to toggle source

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
search_paths(platform, target_name = nil, use_modular_headers = false) click to toggle source

@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
Also aliased as: new_search_paths
user_clang_module=(user_clang_module) click to toggle source
# File lib/cocoapods-headermap/headers_store.rb, line 18
def user_clang_module=(user_clang_module)
    @user_clang_module = user_clang_module
end