Class: XcodeArchiveCache::Injection::Injector

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

Instance Method Summary collapse

Methods included from Logs

#debug, #error, #info, #set_log_level

Constructor Details

#initialize(configuration_name, storage) ⇒ Injector

Returns a new instance of Injector.

Parameters:



10
11
12
13
14
15
16
17
18
# File 'lib/injection/injector.rb', line 10

def initialize(configuration_name, storage)
  @configuration_name = configuration_name
  @storage = storage
  @headers_mover = HeadersMover.new(storage)
  @dependency_remover = DependencyRemover.new
  @build_flags_changer = BuildFlagsChanger.new
  @pods_fixer = PodsScriptFixer.new
  @framework_embedder = FrameworkEmbedder.new
end

Instance Method Details

#perform_internal_injection(graph) ⇒ Object



22
23
24
25
26
# File 'lib/injection/injector.rb', line 22

def perform_internal_injection(graph)
  inject_cached(graph.nodes)
  add_header_paths(graph.nodes)
  save_graph_projects(graph)
end

#perform_outgoing_injection(graph, target) ⇒ Object

Parameters:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/injection/injector.rb', line 31

def perform_outgoing_injection(graph, target)
  root_node = graph.root_node
  if root_node.native_target.project == target.project && root_node.native_target.uuid == target.uuid
    return
  end

  graph.nodes.each do |node|
    headers_mover.prepare_headers_for_injection(node)
    add_as_prebuilt_dependency(node, target, node.is_root)
    remove_native_target_from_project(node)
  end

  add_header_paths_to_target(target, storage.get_all_headers_storage_paths)

  # pretty dummy but should work in most cases;
  # here we assume that if graph has a pods target
  # then all graph nodes are built as pods and therefore
  # are covered by "Embed Pods Frameworks" script
  #
  if graph.node_by_name(get_pods_target_name(target))
    pods_fixer.fix_embed_frameworks_script(target, graph, storage.container_dir_path)
  else
    framework_nodes = graph.nodes.select {|node| node.has_framework_product?}
    framework_file_paths = framework_nodes.map {|node| File.join(storage.get_storage_path(node), node.product_file_name)}
    framework_embedder.embed(framework_file_paths, target)
  end

  save_graph_projects(graph)
  target.project.save
end