Class: Xcake::TargetBuildPhaseGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/xcake/generator/target_build_phase_generator.rb

Overview

This generator generates the build phases for each target in the project

Instance Attribute Summary

Attributes inherited from Generator

#context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#initialize, plugins_location

Methods included from CoreExtensions::ClassDescendants

#descendants

Methods included from Visitor

#item_name, #leave, #visit

Methods included from Plugin

included

Methods included from Dependency

included

Constructor Details

This class inherits a constructor from Xcake::Generator

Class Method Details

.dependenciesObject



6
7
8
# File 'lib/xcake/generator/target_build_phase_generator.rb', line 6

def self.dependencies
  [TargetGenerator, TargetDependencyGenerator, TargetFileReferenceGenerator]
end

Instance Method Details

#create_embed_watchapp_extension_phase(native_target, native_watchapp_extension_target) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/xcake/generator/target_build_phase_generator.rb', line 53

def create_embed_watchapp_extension_phase(native_target, native_watchapp_extension_target)
  EventHooks.run_hook :before_adding_embed_watch_extension_phase

  product_reference = native_watchapp_extension_target.product_reference
  phase = native_target.new_copy_files_build_phase('Embed App Extensions')
  phase.symbol_dst_subfolder_spec = :plug_ins
  phase.add_file_reference(product_reference, true)
  phase
end

#create_embed_watchapp_phase(native_target, native_watchapp_target) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/xcake/generator/target_build_phase_generator.rb', line 43

def create_embed_watchapp_phase(native_target, native_watchapp_target)
  EventHooks.run_hook :before_adding_embed_watch_app_phase

  phase = native_target.new_copy_files_build_phase('Embed Watch Content')
  phase.dst_path = '$(CONTENTS_FOLDER_PATH)/Watch'
  phase.symbol_dst_subfolder_spec = :products_directory
  phase.add_file_reference(native_watchapp_target.product_reference, true)
  phase
end

#visit_target(target) ⇒ Object



10
11
12
13
14
15
16
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
# File 'lib/xcake/generator/target_build_phase_generator.rb', line 10

def visit_target(target)
  EventHooks.run_hook :before_adding_build_phases, target

  native_target = @context.native_object_for(target)

  target.pinned_build_phases.each do |phase|
    EventHooks.run_hook :before_adding_custom_build_phase, phase, target

    native_build_phase = @context.native_object_for(phase)
    phase.configure_native_build_phase(native_build_phase, @context)
    native_target.build_phases.unshift(native_build_phase)
  end

  target.build_phases.each do |phase|
    EventHooks.run_hook :before_adding_custom_build_phase, phase, target

    native_build_phase = @context.native_object_for(phase)
    phase.configure_native_build_phase(native_build_phase, @context)
    native_target.build_phases << native_build_phase
  end

  target.target_dependencies.each do |dep|
    native_dep = @context.native_object_for(dep)

    case dep.type
    when :watch2_app
      create_embed_watchapp_phase(native_target, native_dep)
    when :watch2_extension
      create_embed_watchapp_extension_phase(native_target, native_dep)
    end
  end
end