class Xcodeproj::Project::Object::PBXNativeTarget


Represents a target handled by Xcode.

def add_file_references(file_references, compiler_flags = {})

Returns:
  • (Array) - the created build files.

Parameters:
  • compiler_flags (String) --
  • file_references (Array) --
def add_file_references(file_references, compiler_flags = {})
  file_references.map do |file|
    extension = File.extname(file.path).downcase
    header_extensions = Constants::HEADER_FILES_EXTENSIONS
    is_header_phase = header_extensions.include?(extension)
    phase = is_header_phase ? headers_build_phase : source_build_phase
    unless build_file = phase.build_file(file)
      build_file = project.new(PBXBuildFile)
      build_file.file_ref = file
      phase.files << build_file
    end
    if compiler_flags && !compiler_flags.empty? && !is_header_phase
      (build_file.settings ||= {}).merge!('COMPILER_FLAGS' => compiler_flags) do |_, old, new|
        [old, new].compact.join(' ')
      end
    end
    yield build_file if block_given?
    build_file
  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|
    next if resources_build_phase.include?(file)
    build_file = project.new(PBXBuildFile)
    build_file.file_ref = file
    resources_build_phase.files << build_file
  end
end

def extension_target_type?

Returns:
  • (Boolean) - Whether the target is an extension.
def extension_target_type?
  case symbol_type
  when :app_extension, :watch_extension, :watch2_extension, :tv_extension
    true
  else
    false
  end
end

def find_or_create_build_phase_by_class(phase_class)

Returns:
  • (AbstractBuildPhase) - the build phase whose class match the given phase_class.

Parameters:
  • phase_class (Class) -- the class of the build phase to find or create.
def find_or_create_build_phase_by_class(phase_class)
  @phases ||= {}
  unless phase_class < AbstractBuildPhase
    raise ArgumentError, "#{phase_class} must be a subclass of #{AbstractBuildPhase.class}"
  end
  @phases[phase_class] ||= build_phases.find { |bp| bp.class == phase_class } ||
    project.new(phase_class).tap { |bp| build_phases << bp }
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
  find_or_create_build_phase_by_class(PBXFrameworksBuildPhase)
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
  find_or_create_build_phase_by_class(PBXHeadersBuildPhase)
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
  find_or_create_build_phase_by_class(PBXResourcesBuildPhase)
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
  find_or_create_build_phase_by_class(PBXSourcesBuildPhase)
end

def symbol_type

Returns:
  • (Symbol) - The type of the target expressed as a symbol.
def symbol_type
  Constants::PRODUCT_TYPE_UTI.key(product_type)
end

def test_target_type?

Returns:
  • (Boolean) - Whether the target is a test target.
def test_target_type?
  case symbol_type
  when :octest_bundle, :unit_test_bundle, :ui_test_bundle
    true
  else
    false
  end
end