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



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/xcodeproj/scheme/build_action.rb', line 178

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_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
    self.build_for_analyzing = true

    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



285
286
287
# File 'lib/xcodeproj/scheme/build_action.rb', line 285

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



268
269
270
# File 'lib/xcodeproj/scheme/build_action.rb', line 268

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



261
262
263
# File 'lib/xcodeproj/scheme/build_action.rb', line 261

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



254
255
256
# File 'lib/xcodeproj/scheme/build_action.rb', line 254

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



247
248
249
# File 'lib/xcodeproj/scheme/build_action.rb', line 247

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



240
241
242
# File 'lib/xcodeproj/scheme/build_action.rb', line 240

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



233
234
235
# File 'lib/xcodeproj/scheme/build_action.rb', line 233

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



226
227
228
# File 'lib/xcodeproj/scheme/build_action.rb', line 226

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



219
220
221
# File 'lib/xcodeproj/scheme/build_action.rb', line 219

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



212
213
214
# File 'lib/xcodeproj/scheme/build_action.rb', line 212

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



205
206
207
# File 'lib/xcodeproj/scheme/build_action.rb', line 205

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)



276
277
278
279
280
# File 'lib/xcodeproj/scheme/build_action.rb', line 276

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

#remove_buildable_reference(ref) ⇒ Object

Parameters:

  • ref (BuildableReference)

    The BuildableReference to remove from the list of targets this entry will build



292
293
294
# File 'lib/xcodeproj/scheme/build_action.rb', line 292

def remove_buildable_reference(ref)
  @xml_element.delete_element(ref.xml_element)
end