class Xcodeproj::Project::Object::PBXNativeTarget


Represents a target handled by Xcode.

def add_file_references(file_references, compiler_flags = {})

Returns:
  • (void) -

Parameters:
  • compiler_flags (Hash{String=>String}) --
  • file_references (Array) --
def add_file_references(file_references, compiler_flags = {})
  file_references.each do |file|
    build_file = project.new(PBXBuildFile)
    build_file.file_ref = file
    extension = File.extname(file.path)
    header_extensions = Constants::HEADER_FILES_EXTENSIONS
    if (header_extensions.include?(extension))
      headers_build_phase.files << build_file
    else
      if compiler_flags && !compiler_flags.empty?
        build_file.settings = { 'COMPILER_FLAGS' => compiler_flags }
      end
      source_build_phase.files << build_file
    end
  end
end

def add_resources(resource_file_references)

Returns:
  • (void) -

Parameters:
  • resource_file_references (Array) --
def add_resources(resource_file_references)
  resource_file_references.each do |file|
    build_file = project.new(PBXBuildFile)
    build_file.file_ref = file
    resources_build_phase.files << build_file
  end
end

def frameworks_build_phase

Returns:
  • (PBXFrameworksBuildPhase) - the frameworks build phase.

Other tags:
    Note: - A target should have only one frameworks build phase.
def frameworks_build_phase
  phase = build_phases.find { |bp| bp.class == PBXFrameworksBuildPhase }
  unless phase
    phase= project.new(PBXFrameworksBuildPhase)
    build_phases << phase
  end
  phase
end

def headers_build_phase

Returns:
  • (PBXHeadersBuildPhase) - the headers build phase.

Other tags:
    Note: - A target should have only one headers build phase.
def headers_build_phase
  unless @headers_build_phase
    headers_build_phase = build_phases.find { |bp| bp.class == PBXHeadersBuildPhase }
    unless headers_build_phase
      # Working around a bug in Xcode 4.2 betas, remove this once the
      # Xcode bug is fixed:
      # https://github.com/alloy/cocoapods/issues/13
      # phase = copy_header_phase || headers_build_phases.first
      headers_build_phase = project.new(PBXHeadersBuildPhase)
      build_phases << headers_build_phase
    end
    @headers_build_phase = headers_build_phase
  end
  @headers_build_phase
end

def resources_build_phase

Returns:
  • (PBXResourcesBuildPhase) - the resources build phase.

Other tags:
    Note: - A target should have only one resources build phase.
def resources_build_phase
  phase = build_phases.find { |bp| bp.class == PBXResourcesBuildPhase }
  unless phase
    phase = project.new(PBXResourcesBuildPhase)
    build_phases << phase
  end
  phase
end

def sort(options = nil)


Build phases are not sorted as they order is relevant.

name.
Sorts the to many attributes of the object according to the display
def sort(options = nil)
  attributes_to_sort = to_many_attributes.reject { |attr| attr.name == :build_phases }
  attributes_to_sort.each do |attrb|
    list = attrb.get_value(self)
    list.sort! do |x, y|
      x.display_name <=> y.display_name
    end
  end
end

def source_build_phase

Returns:
  • (PBXSourcesBuildPhase) - the source build phase.

Other tags:
    Note: - A target should have only one source build phase.
def source_build_phase
  unless @source_build_phase
    source_build_phase = build_phases.find { |bp| bp.class == PBXSourcesBuildPhase }
    unless source_build_phase
      source_build_phase = project.new(PBXSourcesBuildPhase)
      build_phases << source_build_phase
    end
    @source_build_phase = source_build_phase
  end
  @source_build_phase
end

def symbol_type

Returns:
  • (Symbol) - The type of the target expressed as a symbol.
def symbol_type
  pair = Constants::PRODUCT_TYPE_UTI.find { |key, value| value == product_type }
  pair.first
end