Class: Xcodeproj::XCScheme::BuildAction::Entry

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

Overview

————————————————————————-#

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 = nil) ⇒ Entry

Returns a new instance of Entry.

Parameters:

  • target_or_node (Xcodeproj::Project::Object::AbstractTarget, REXML::Element) (defaults to: nil)

    Either the Xcode target to reference, or an existing XML ‘BuildActionEntry’ node element to reference, or nil to create an new, empty Entry with default values



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/xcodeproj/scheme/build_action.rb', line 78

def initialize(target_or_node = nil)
  create_xml_element_with_fallback(target_or_node, 'BuildActionEntry') do
    # Check target type to configure the default entry attributes accordingly
    is_test_target = false
    is_app_target = false
    if target_or_node && target_or_node.is_a?(::Xcodeproj::Project::Object::PBXNativeTarget)
      test_types = [Constants::PRODUCT_TYPE_UTI[:octest_bundle],
                    Constants::PRODUCT_TYPE_UTI[:unit_test_bundle],
                    Constants::PRODUCT_TYPE_UTI[:ui_test_bundle]]
      app_types = [Constants::PRODUCT_TYPE_UTI[:application]]
      is_test_target = test_types.include?(target_or_node.product_type)
      is_app_target = app_types.include?(target_or_node.product_type)
    end

    self.build_for_analyzing = true
    self.build_for_testing   = is_test_target
    self.build_for_running   = is_app_target
    self.build_for_profiling = is_app_target
    self.build_for_archiving = is_app_target

    add_buildable_reference BuildableReference.new(target_or_node) if target_or_node
  end
end

Instance Method Details

#add_buildable_reference(ref) ⇒ Object

Parameters:

  • ref (BuildableReference)

    The BuildableReference to add to the list of targets this entry will build



185
186
187
# File 'lib/xcodeproj/scheme/build_action.rb', line 185

def add_buildable_reference(ref)
  @xml_element.add_element(ref.xml_element)
end

#build_for_analyzing=(flag) ⇒ Object

Parameters:

  • Set (Bool)

    whether or not to build this target when building for Analyzing



168
169
170
# File 'lib/xcodeproj/scheme/build_action.rb', line 168

def build_for_analyzing=(flag)
  @xml_element.attributes['buildForAnalyzing'] = bool_to_string(flag)
end

#build_for_analyzing?Bool

Returns Whether or not to build this target when building for Analyzing.

Returns:

  • (Bool)

    Whether or not to build this target when building for Analyzing



161
162
163
# File 'lib/xcodeproj/scheme/build_action.rb', line 161

def build_for_analyzing?
  string_to_bool(@xml_element.attributes['buildForAnalyzing'])
end

#build_for_archiving=(flag) ⇒ Object

Parameters:

  • Set (Bool)

    whether or not to build this target when building for Archiving



154
155
156
# File 'lib/xcodeproj/scheme/build_action.rb', line 154

def build_for_archiving=(flag)
  @xml_element.attributes['buildForArchiving'] = bool_to_string(flag)
end

#build_for_archiving?Bool

Returns Whether or not to build this target when building for Archiving.

Returns:

  • (Bool)

    Whether or not to build this target when building for Archiving



147
148
149
# File 'lib/xcodeproj/scheme/build_action.rb', line 147

def build_for_archiving?
  string_to_bool(@xml_element.attributes['buildForArchiving'])
end

#build_for_profiling=(flag) ⇒ Object

Parameters:

  • Set (Bool)

    whether or not to build this target when building for Profiling



140
141
142
# File 'lib/xcodeproj/scheme/build_action.rb', line 140

def build_for_profiling=(flag)
  @xml_element.attributes['buildForProfiling'] = bool_to_string(flag)
end

#build_for_profiling?Bool

Returns Whether or not to build this target when building for Profiling.

Returns:

  • (Bool)

    Whether or not to build this target when building for Profiling



133
134
135
# File 'lib/xcodeproj/scheme/build_action.rb', line 133

def build_for_profiling?
  string_to_bool(@xml_element.attributes['buildForProfiling'])
end

#build_for_running=(flag) ⇒ Object

Parameters:

  • Set (Bool)

    whether or not to build this target when building for Running



126
127
128
# File 'lib/xcodeproj/scheme/build_action.rb', line 126

def build_for_running=(flag)
  @xml_element.attributes['buildForRunning'] = bool_to_string(flag)
end

#build_for_running?Bool

Returns Whether or not to build this target when building for Running.

Returns:

  • (Bool)

    Whether or not to build this target when building for Running



119
120
121
# File 'lib/xcodeproj/scheme/build_action.rb', line 119

def build_for_running?
  string_to_bool(@xml_element.attributes['buildForRunning'])
end

#build_for_testing=(flag) ⇒ Object

Parameters:

  • Set (Bool)

    whether or not to build this target when building for Testing



112
113
114
# File 'lib/xcodeproj/scheme/build_action.rb', line 112

def build_for_testing=(flag)
  @xml_element.attributes['buildForTesting'] = bool_to_string(flag)
end

#build_for_testing?Bool

Returns Whether or not to build this target when building for Testing.

Returns:

  • (Bool)

    Whether or not to build this target when building for Testing



105
106
107
# File 'lib/xcodeproj/scheme/build_action.rb', line 105

def build_for_testing?
  string_to_bool(@xml_element.attributes['buildForTesting'])
end

#buildable_referencesArray<BuildableReference>

Returns The list of BuildableReferences this entry will build. (The list usually contains only one element).

Returns:

  • (Array<BuildableReference>)

    The list of BuildableReferences this entry will build. (The list usually contains only one element)



176
177
178
179
180
# File 'lib/xcodeproj/scheme/build_action.rb', line 176

def buildable_references
  @xml_element.get_elements('BuildableReference').map do |node|
    BuildableReference.new(node)
  end
end