Class: Xcodeproj::XCScheme::LaunchAction

Inherits:
AbstractSchemeAction show all
Defined in:
lib/xcodeproj/scheme/launch_action.rb

Overview

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

Instance Attribute Summary

Attributes inherited from XMLElementWrapper

#xml_element

Instance Method Summary collapse

Methods inherited from AbstractSchemeAction

#add_post_action, #add_pre_action, #build_configuration, #build_configuration=, #post_actions, #post_actions=, #pre_actions, #pre_actions=

Methods inherited from XMLElementWrapper

#to_s

Constructor Details

#initialize(node = nil) ⇒ LaunchAction

Returns a new instance of LaunchAction.

Parameters:

  • node (REXML::Element) (defaults to: nil)

    The 'LaunchAction' XML node that this object will wrap. If nil, will create a default XML node to use.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/xcodeproj/scheme/launch_action.rb', line 12

def initialize(node = nil)
  create_xml_element_with_fallback(node, 'LaunchAction') do
    self.build_configuration = 'Debug'

    # Add some attributes (that are not handled by this wrapper class yet but expected in the XML)
    @xml_element.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
    @xml_element.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
    @xml_element.attributes['launchStyle'] = '0'
    @xml_element.attributes['useCustomWorkingDirectory'] = bool_to_string(false)
    @xml_element.attributes['ignoresPersistentStateOnLaunch'] = bool_to_string(false)
    @xml_element.attributes['debugDocumentVersioning'] = bool_to_string(true)
    @xml_element.attributes['debugServiceExtension'] = 'internal'

    # Setup default values for other (handled) attributes
    self.allow_location_simulation = true
  end
end

Instance Method Details

#add_macro_expansion(macro_expansion) ⇒ Object

Parameters:

  • macro_expansion (MacroExpansion)

    Add a MacroExpansion to this LaunchAction



174
175
176
# File 'lib/xcodeproj/scheme/launch_action.rb', line 174

def add_macro_expansion(macro_expansion)
  @xml_element.add_element(macro_expansion.xml_element)
end

#allow_location_simulation=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether or not to allow GPS location simulation when launching this target



46
47
48
# File 'lib/xcodeproj/scheme/launch_action.rb', line 46

def allow_location_simulation=(flag)
  @xml_element.attributes['allowLocationSimulation'] = bool_to_string(flag)
end

#allow_location_simulation?Bool

Returns Whether or not to allow GPS location simulation when launching this target.

Returns:

  • (Bool)

    Whether or not to allow GPS location simulation when launching this target



39
40
41
# File 'lib/xcodeproj/scheme/launch_action.rb', line 39

def allow_location_simulation?
  string_to_bool(@xml_element.attributes['allowLocationSimulation'])
end

#buildable_product_runnableBuildableProductRunnable

Returns The BuildReference to launch when executing the Launch Action.

Returns:



116
117
118
# File 'lib/xcodeproj/scheme/launch_action.rb', line 116

def buildable_product_runnable
  BuildableProductRunnable.new(@xml_element.elements['BuildableProductRunnable'], 0)
end

#buildable_product_runnable=(runnable) ⇒ Object

Parameters:



123
124
125
126
# File 'lib/xcodeproj/scheme/launch_action.rb', line 123

def buildable_product_runnable=(runnable)
  @xml_element.delete_element('BuildableProductRunnable')
  @xml_element.add_element(runnable.xml_element) if runnable
end

#command_line_argumentsCommandLineArguments

Returns the CommandLineArguments that will be passed at app launch

Returns:



149
150
151
# File 'lib/xcodeproj/scheme/launch_action.rb', line 149

def command_line_arguments
  CommandLineArguments.new(@xml_element.elements[XCScheme::COMMAND_LINE_ARGS_NODE])
end

#command_line_arguments=(arguments) ⇒ CommandLineArguments

Returns arguments Sets the CommandLineArguments that will be passed at app launch.

Returns:

  • (CommandLineArguments)

    arguments Sets the CommandLineArguments that will be passed at app launch



156
157
158
159
160
# File 'lib/xcodeproj/scheme/launch_action.rb', line 156

def command_line_arguments=(arguments)
  @xml_element.delete_element(XCScheme::COMMAND_LINE_ARGS_NODE)
  @xml_element.add_element(arguments.xml_element) if arguments
  arguments
end

#disable_main_thread_checker=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether this Build Action should disable detection of UI API misuse from background threads



77
78
79
# File 'lib/xcodeproj/scheme/launch_action.rb', line 77

def disable_main_thread_checker=(flag)
  @xml_element.attributes['disableMainThreadChecker'] = bool_to_string(flag)
end

#disable_main_thread_checker?Bool

Returns Whether this Build Action should disable detection of UI API misuse from background threads.

Returns:

  • (Bool)

    Whether this Build Action should disable detection of UI API misuse from background threads



69
70
71
# File 'lib/xcodeproj/scheme/launch_action.rb', line 69

def disable_main_thread_checker?
  string_to_bool(@xml_element.attributes['disableMainThreadChecker'])
end

#environment_variablesEnvironmentVariables

Returns the EnvironmentVariables that will be defined at app launch

Returns:



131
132
133
# File 'lib/xcodeproj/scheme/launch_action.rb', line 131

def environment_variables
  EnvironmentVariables.new(@xml_element.elements[XCScheme::VARIABLES_NODE])
end

#environment_variables=(env_vars) ⇒ Object

Parameters:

  • env_vars (EnvironmentVariables, nil)

    Sets the EnvironmentVariables that will be defined at app launch



138
139
140
141
142
# File 'lib/xcodeproj/scheme/launch_action.rb', line 138

def environment_variables=(env_vars)
  @xml_element.delete_element(XCScheme::VARIABLES_NODE)
  @xml_element.add_element(env_vars.xml_element) if env_vars
  env_vars
end

#launch_automatically_substyleString

Returns The launch automatically substyle.

Returns:

  • (String)

    The launch automatically substyle



102
103
104
# File 'lib/xcodeproj/scheme/launch_action.rb', line 102

def launch_automatically_substyle
  @xml_element.attributes['launchAutomaticallySubstyle']
end

#launch_automatically_substyle=(value) ⇒ Object

Parameters:

  • flag (String)

    Set the launch automatically substyle ('2' for extensions)



109
110
111
# File 'lib/xcodeproj/scheme/launch_action.rb', line 109

def launch_automatically_substyle=(value)
  @xml_element.attributes['launchAutomaticallySubstyle'] = value.to_s
end

#location_scenario_reference=(reference) ⇒ LocationScenarioReference

Returns Set the LocationScenarioReference which simulates a GPS location when executing the Launch Action.

Returns:

  • (LocationScenarioReference)

    Set the LocationScenarioReference which simulates a GPS location when executing the Launch Action



60
61
62
63
# File 'lib/xcodeproj/scheme/launch_action.rb', line 60

def location_scenario_reference=(reference)
  @xml_element.delete_element('LocationScenarioReference')
  @xml_element.add_element(reference.xml_element) if reference
end

#location_scenario_reference?LocationScenarioReference

Returns The LocationScenarioReference to simulate a GPS location when executing the Launch Action.

Returns:



53
54
55
# File 'lib/xcodeproj/scheme/launch_action.rb', line 53

def location_scenario_reference?
  LocationScenarioReference.new(@xml_element.elements['LocationScenarioReference'])
end

#macro_expansionsArray<MacroExpansion>

Returns The list of MacroExpansion bound with this LaunchAction.

Returns:

  • (Array<MacroExpansion>)

    The list of MacroExpansion bound with this LaunchAction



165
166
167
168
169
# File 'lib/xcodeproj/scheme/launch_action.rb', line 165

def macro_expansions
  @xml_element.get_elements('MacroExpansion').map do |node|
    MacroExpansion.new(node)
  end
end

#stop_on_every_main_thread_checker_issue=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether UI API misuse from background threads detection should pause execution. This flag is ignored when the thread checker disabled ([disable_main_thread_checker] flag).



95
96
97
# File 'lib/xcodeproj/scheme/launch_action.rb', line 95

def stop_on_every_main_thread_checker_issue=(flag)
  @xml_element.attributes['stopOnEveryMainThreadCheckerIssue'] = bool_to_string(flag)
end

#stop_on_every_main_thread_checker_issue?Bool

Returns Whether UI API misuse from background threads detection should pause execution. This flag is ignored when the thread checker disabled ([disable_main_thread_checker] flag).

Returns:

  • (Bool)

    Whether UI API misuse from background threads detection should pause execution. This flag is ignored when the thread checker disabled ([disable_main_thread_checker] flag).



86
87
88
# File 'lib/xcodeproj/scheme/launch_action.rb', line 86

def stop_on_every_main_thread_checker_issue?
  string_to_bool(@xml_element.attributes['stopOnEveryMainThreadCheckerIssue'])
end