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) ⇒ BuildableReference

Returns a new instance of BuildableReference.

Parameters:



13
14
15
16
17
18
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 13

def initialize(target_or_node)
  create_xml_element_with_fallback(target_or_node, 'BuildableReference') do
    @xml_element.attributes['BuildableIdentifier'] = 'primary'
    set_reference_target(target_or_node, true) 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



65
66
67
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 65

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



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

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

#set_reference_target(target, override_buildable_name = false) ⇒ 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.

  • override_buildable_name (Bool) (defaults to: false)

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



55
56
57
58
59
60
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 55

def set_reference_target(target, override_buildable_name = false)
  @xml_element.attributes['BlueprintIdentifier'] = target.uuid
  @xml_element.attributes['BlueprintName'] = target.name
  @xml_element.attributes['ReferencedContainer'] = construct_referenced_container_uri(target)
  self.buildable_name = construct_buildable_name(target) if override_buildable_name
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



23
24
25
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 23

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’



42
43
44
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 42

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.



34
35
36
# File 'lib/xcodeproj/scheme/buildable_reference.rb', line 34

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