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



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



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

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

#buildable_name=(value) ⇒ Object



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


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



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

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

#target_referenced_containerString



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.



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

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