Class: XcodeArchiveCache::Injection::HeadersMover

Inherits:
Object
  • Object
show all
Includes:
Logs
Defined in:
lib/injection/headers_mover.rb

Instance Method Summary collapse

Methods included from Logs

#debug, #error, #info, #set_log_level

Constructor Details

#initialize(storage) ⇒ HeadersMover

Returns a new instance of HeadersMover.

Parameters:



9
10
11
12
13
# File 'lib/injection/headers_mover.rb', line 9

def initialize(storage)
  @storage = storage
  @build_settings_interpolator = XcodeArchiveCache::BuildSettings::StringInterpolator.new
  @modulemap_header_path_extractor = XcodeArchiveCache::Modulemap::HeaderPathExtractor.new
end

Instance Method Details

#prepare_headers_for_injection(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/injection/headers_mover.rb', line 17

def prepare_headers_for_injection(node)
  debug("checking #{node.name} headers")
  header_count = 0

  node.native_target.copy_files_build_phases.each do |build_phase|
    file_paths = build_phase.files
                     .map { |build_file| get_real_path(build_file) }
                     .compact
                     .uniq
                     .select { |path| File.extname(path) == ".h" }
    destination_path = get_destination_dir_path(node, build_phase)
    storage.store_headers(node, destination_path, file_paths)

    header_count += file_paths.length
  end

  if node.has_static_library_product?
    headers_file_paths = node.native_target
                             .headers_build_phase
                             .files
                             .select { |file| file.settings && file.settings["ATTRIBUTES"].include?("Public") }
                             .map { |header| get_real_path(header) }
                             .uniq
    storage.store_default_headers(node, headers_file_paths)

    header_count += headers_file_paths.length
  end

  modulemap_file_path = node.original_modulemap_file_path
  if modulemap_file_path && File.exist?(modulemap_file_path)
    header_file_paths = modulemap_header_path_extractor.extract_all_paths(modulemap_file_path)
    storage.store_modulemap_headers(node, header_file_paths)
    header_count += header_file_paths.length
  end

  debug("found #{header_count} header(s)")
end