Class: Xcodeproj::XCScheme::BuildableReference

Inherits:
XMLElementWrapper show all
Defined in:
lib/xcodeproj/scheme/buildable_reference.rb

Overview

This class wraps the BuildableReference node of a .xcscheme XML file

A BuildableReference is a reference to a buildable product (which is typically is synonymous for an Xcode target)

Instance Attribute Summary

Attributes inherited from XMLElementWrapper

#xml_element

Instance Method Summary collapse

Methods inherited from XMLElementWrapper

#to_s

Constructor Details

#initialize(target_or_node, root_project = nil) ⇒ BuildableReference

Returns a new instance of BuildableReference.

Parameters:



16
17
18
19
20
21
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 16

def initialize(target_or_node, root_project = nil)
  create_xml_element_with_fallback(target_or_node, 'BuildableReference') do
    @xml_element.attributes['BuildableIdentifier'] = 'primary'
    set_reference_target(target_or_node, true, root_project) if target_or_node
  end
end

Instance Method Details

#buildable_nameString

Returns The name of the final product when building this Buildable Reference.

Returns:

  • (String)

    The name of the final product when building this Buildable Reference



73
74
75
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 73

def buildable_name
  @xml_element.attributes['BuildableName']
end

#buildable_name=(value) ⇒ Object

Parameters:

  • value (String)

    Set the name of the final product when building this Buildable Reference



80
81
82
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 80

def buildable_name=(value)
  @xml_element.attributes['BuildableName'] = value
end

#set_reference_target(target, override_buildable_name = false, root_project = nil) ⇒ Object

Set the BlueprintIdentifier (target.uuid), BlueprintName (target.name)

and TerefencedContainer (URI pointing to target's projet) all at once

Parameters:

  • target (Xcodeproj::Project::Object::AbstractTarget)

    The target this BuildableReference refers to.

  • the (Xcodeproj::Project)

    root project to reference from (when nil the project of the target is used)

  • override_buildable_name (Bool) (defaults to: false)

    If true, buildable_name will also be updated by computing a name from the target



61
62
63
64
65
66
67
68
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 61

def set_reference_target(target, override_buildable_name = false, root_project = nil)
  # note, the order of assignment here is important, it determines the order of serialization in the xml
  # this matches the order that Xcode generates
  @xml_element.attributes['BlueprintIdentifier'] = target.uuid
  self.buildable_name = construct_buildable_name(target) if override_buildable_name
  @xml_element.attributes['BlueprintName'] = target.name
  @xml_element.attributes['ReferencedContainer'] = construct_referenced_container_uri(target, root_project)
end

#target_nameString

Returns The name of the target this Buildable Reference points to.

Returns:

  • (String)

    The name of the target this Buildable Reference points to



26
27
28
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 26

def target_name
  @xml_element.attributes['BlueprintName']
end

#target_referenced_containerString

Returns The string representing the container of that target. Typically in the form of ‘container:xxxx.xcodeproj’.

Returns:

  • (String)

    The string representing the container of that target. Typically in the form of ‘container:xxxx.xcodeproj’



45
46
47
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 45

def target_referenced_container
  @xml_element.attributes['ReferencedContainer']
end

#target_uuidString

Note:

You can use this to ‘#find` the `Xcodeproj::Project::Object::AbstractTarget` instance in your Xcodeproj::Project object. e.g. `project.targets.find { |t| t.uuid == ref.target_uuid }`

Returns The Unique Identifier of the target (target.uuid) this Buildable Reference points to.

Returns:

  • (String)

    The Unique Identifier of the target (target.uuid) this Buildable Reference points to.



37
38
39
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 37

def target_uuid
  @xml_element.attributes['BlueprintIdentifier']
end