Class: Pod::Sandbox::HeadersStore
- Inherits:
-
Object
- Object
- Pod::Sandbox::HeadersStore
- Defined in:
- lib/cocoapods/sandbox/headers_store.rb
Overview
Provides support for managing a header directory. It also keeps track of the header search paths.
Defined Under Namespace
Classes: SEARCH_PATHS_KEY
Instance Attribute Summary collapse
-
#sandbox ⇒ Sandbox
readonly
The sandbox where this header directory is stored.
Adding headers collapse
-
#add_file(namespace, relative_header_path, mkdir: true) ⇒ Pathname
Adds a header to the directory.
-
#add_files(namespace, relative_header_paths) ⇒ Array<Pathname>
Adds headers to the directory.
-
#add_search_path(path, platform) ⇒ void
Adds an header search path to the sandbox.
Instance Method Summary collapse
-
#implode! ⇒ void
Removes the directory as it is regenerated from scratch during each installation.
-
#initialize(sandbox, relative_path, visibility_scope) ⇒ HeadersStore
constructor
A new instance of HeadersStore.
-
#root ⇒ Pathname
The absolute path of this header directory.
-
#search_paths(platform, target_name = nil, use_modular_headers = false) ⇒ Array<String>
All the search paths of the header directory in xcconfig format.
Constructor Details
#initialize(sandbox, relative_path, visibility_scope) ⇒ HeadersStore
Returns a new instance of HeadersStore.
28 29 30 31 32 33 34 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 28 def initialize(sandbox, relative_path, visibility_scope) @sandbox = sandbox @relative_path = relative_path @search_paths = [] @search_paths_cache = {} @visibility_scope = visibility_scope end |
Instance Attribute Details
#sandbox ⇒ Sandbox (readonly)
Returns the sandbox where this header directory is stored.
17 18 19 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 17 def sandbox @sandbox end |
Instance Method Details
#add_file(namespace, relative_header_path, mkdir: true) ⇒ Pathname
This method does not add the file to the search paths.
Adds a header to the directory.
119 120 121 122 123 124 125 126 127 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 119 def add_file(namespace, relative_header_path, mkdir: true) namespaced_path = root + namespace namespaced_path.mkpath if mkdir absolute_source = (sandbox.root + relative_header_path) source = absolute_source.relative_path_from(namespaced_path) FileUtils.ln_sf(source, namespaced_path) namespaced_path + relative_header_path.basename end |
#add_files(namespace, relative_header_paths) ⇒ Array<Pathname>
This method does not add the files to the search paths.
Adds headers to the directory.
98 99 100 101 102 103 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 98 def add_files(namespace, relative_header_paths) root.join(namespace).mkpath unless relative_header_paths.empty? relative_header_paths.map do |relative_header_path| add_file(namespace, relative_header_path, :mkdir => false) end end |
#add_search_path(path, platform) ⇒ void
This method returns an undefined value.
Adds an header search path to the sandbox.
139 140 141 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 139 def add_search_path(path, platform) @search_paths << { :platform => platform.name, :path => File.join(@relative_path, path) } end |
#implode! ⇒ void
This method returns an undefined value.
Removes the directory as it is regenerated from scratch during each installation.
74 75 76 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 74 def implode! root.rmtree if root.exist? end |
#root ⇒ Pathname
Returns the absolute path of this header directory.
11 12 13 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 11 def root sandbox.headers_root + @relative_path end |
#search_paths(platform, target_name = nil, use_modular_headers = false) ⇒ Array<String>
Returns All the search paths of the header directory in xcconfig format. The paths are specified relative to the pods root with the ‘$PODS_ROOT` variable.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cocoapods/sandbox/headers_store.rb', line 52 def search_paths(platform, target_name = nil, use_modular_headers = false) key = SEARCH_PATHS_KEY.new(platform.name, target_name, use_modular_headers) return @search_paths_cache[key] if @search_paths_cache.key?(key) search_paths = @search_paths.select do |entry| matches_platform = entry[:platform] == platform.name matches_target = target_name.nil? || (File.basename(entry[:path]) == target_name) matches_platform && matches_target end headers_dir = root.relative_path_from(sandbox.root).dirname @search_paths_cache[key] = search_paths.flat_map do |entry| paths = [] paths << "${PODS_ROOT}/#{headers_dir}/#{@relative_path}" if !use_modular_headers || @visibility_scope == :public paths << "${PODS_ROOT}/#{headers_dir}/#{entry[:path]}" if !use_modular_headers || @visibility_scope == :private paths end.tap(&:uniq!).freeze end |