Sha256: cd17612340744f074e8ba1c4d3a3a5367cc2d1d5c59920939d5504235d28c1f2

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

module Xcake
  # TODO: In future this should just infer extra targets and add it to the DSL
  # we should then implement a 2nd pass generator which turns that DSL into
  # build phases
  class TargetBuildPhaseGenerator < Generator
    def self.dependencies
      [TargetGenerator, TargetDependencyGenerator]
    end

    def visit_target(target)
      puts "Generating build phases for #{target}..."

      native_target = @context.native_object_for(target)

      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

    def create_embed_watchapp_phase(native_target, native_watchapp_target)
      puts 'Generating 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

    def create_embed_watchapp_extension_phase(native_target, native_watchapp_extension_target)
      puts 'Generating embed watch app 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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xcake-0.6.20 lib/xcake/generator/target_build_phase_generator.rb