plasmo_xcodeproj 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +19 -0
  3. data/README.md +95 -0
  4. data/bin/xcodeproj +10 -0
  5. data/lib/xcodeproj/command/config_dump.rb +91 -0
  6. data/lib/xcodeproj/command/project_diff.rb +56 -0
  7. data/lib/xcodeproj/command/show.rb +60 -0
  8. data/lib/xcodeproj/command/sort.rb +44 -0
  9. data/lib/xcodeproj/command/target_diff.rb +43 -0
  10. data/lib/xcodeproj/command.rb +63 -0
  11. data/lib/xcodeproj/config/other_linker_flags_parser.rb +73 -0
  12. data/lib/xcodeproj/config.rb +386 -0
  13. data/lib/xcodeproj/constants.rb +465 -0
  14. data/lib/xcodeproj/differ.rb +239 -0
  15. data/lib/xcodeproj/gem_version.rb +5 -0
  16. data/lib/xcodeproj/helper.rb +30 -0
  17. data/lib/xcodeproj/plist.rb +94 -0
  18. data/lib/xcodeproj/project/case_converter.rb +90 -0
  19. data/lib/xcodeproj/project/object/build_configuration.rb +255 -0
  20. data/lib/xcodeproj/project/object/build_file.rb +84 -0
  21. data/lib/xcodeproj/project/object/build_phase.rb +369 -0
  22. data/lib/xcodeproj/project/object/build_rule.rb +109 -0
  23. data/lib/xcodeproj/project/object/configuration_list.rb +117 -0
  24. data/lib/xcodeproj/project/object/container_item_proxy.rb +116 -0
  25. data/lib/xcodeproj/project/object/file_reference.rb +338 -0
  26. data/lib/xcodeproj/project/object/group.rb +506 -0
  27. data/lib/xcodeproj/project/object/helpers/build_settings_array_settings_by_object_version.rb +72 -0
  28. data/lib/xcodeproj/project/object/helpers/file_references_factory.rb +245 -0
  29. data/lib/xcodeproj/project/object/helpers/groupable_helper.rb +260 -0
  30. data/lib/xcodeproj/project/object/native_target.rb +751 -0
  31. data/lib/xcodeproj/project/object/reference_proxy.rb +86 -0
  32. data/lib/xcodeproj/project/object/root_object.rb +100 -0
  33. data/lib/xcodeproj/project/object/swift_package_product_dependency.rb +29 -0
  34. data/lib/xcodeproj/project/object/swift_package_remote_reference.rb +33 -0
  35. data/lib/xcodeproj/project/object/target_dependency.rb +94 -0
  36. data/lib/xcodeproj/project/object.rb +534 -0
  37. data/lib/xcodeproj/project/object_attributes.rb +522 -0
  38. data/lib/xcodeproj/project/object_dictionary.rb +210 -0
  39. data/lib/xcodeproj/project/object_list.rb +223 -0
  40. data/lib/xcodeproj/project/project_helper.rb +341 -0
  41. data/lib/xcodeproj/project/uuid_generator.rb +132 -0
  42. data/lib/xcodeproj/project.rb +874 -0
  43. data/lib/xcodeproj/scheme/abstract_scheme_action.rb +100 -0
  44. data/lib/xcodeproj/scheme/analyze_action.rb +19 -0
  45. data/lib/xcodeproj/scheme/archive_action.rb +59 -0
  46. data/lib/xcodeproj/scheme/build_action.rb +298 -0
  47. data/lib/xcodeproj/scheme/buildable_product_runnable.rb +55 -0
  48. data/lib/xcodeproj/scheme/buildable_reference.rb +129 -0
  49. data/lib/xcodeproj/scheme/command_line_arguments.rb +162 -0
  50. data/lib/xcodeproj/scheme/environment_variables.rb +170 -0
  51. data/lib/xcodeproj/scheme/execution_action.rb +86 -0
  52. data/lib/xcodeproj/scheme/launch_action.rb +179 -0
  53. data/lib/xcodeproj/scheme/location_scenario_reference.rb +49 -0
  54. data/lib/xcodeproj/scheme/macro_expansion.rb +34 -0
  55. data/lib/xcodeproj/scheme/profile_action.rb +57 -0
  56. data/lib/xcodeproj/scheme/remote_runnable.rb +92 -0
  57. data/lib/xcodeproj/scheme/send_email_action_content.rb +84 -0
  58. data/lib/xcodeproj/scheme/shell_script_action_content.rb +77 -0
  59. data/lib/xcodeproj/scheme/test_action.rb +394 -0
  60. data/lib/xcodeproj/scheme/xml_element_wrapper.rb +82 -0
  61. data/lib/xcodeproj/scheme.rb +375 -0
  62. data/lib/xcodeproj/user_interface.rb +22 -0
  63. data/lib/xcodeproj/workspace/file_reference.rb +79 -0
  64. data/lib/xcodeproj/workspace/group_reference.rb +67 -0
  65. data/lib/xcodeproj/workspace/reference.rb +40 -0
  66. data/lib/xcodeproj/workspace.rb +277 -0
  67. data/lib/xcodeproj/xcodebuild_helper.rb +108 -0
  68. data/lib/xcodeproj.rb +29 -0
  69. metadata +208 -0
@@ -0,0 +1,162 @@
1
+ require 'xcodeproj/scheme/xml_element_wrapper'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ COMMAND_LINE_ARGS_NODE = 'CommandLineArguments'.freeze
6
+ COMMAND_LINE_ARG_NODE = 'CommandLineArgument'.freeze
7
+
8
+ # This class wraps the CommandLineArguments node of a .xcscheme XML file. This
9
+ # is just a container of CommandLineArgument objects. It can either appear on a
10
+ # LaunchAction or TestAction scheme group.
11
+ #
12
+ class CommandLineArguments < XMLElementWrapper
13
+ # @param [nil,REXML::Element,Array<CommandLineArgument>,Array<Hash{Symbol => String,Bool}>] node_or_arguments
14
+ # The 'CommandLineArguments' XML node, or list of command line arguments, that this object represents.
15
+ # - If nil, an empty 'CommandLineArguments' XML node will be created
16
+ # - If an REXML::Element, it must be named 'CommandLineArguments'
17
+ # - If an Array of objects or Hashes, they'll each be passed to {#assign_argument}
18
+ #
19
+ def initialize(node_or_arguments = nil)
20
+ create_xml_element_with_fallback(node_or_arguments, COMMAND_LINE_ARGS_NODE) do
21
+ @all_arguments = []
22
+ node_or_arguments.each { |var| assign_argument(var) } unless node_or_arguments.nil?
23
+ end
24
+ end
25
+
26
+ # @return [Array<CommandLineArgument>]
27
+ # The key value pairs currently set in @xml_element
28
+ #
29
+ def all_arguments
30
+ @all_arguments ||= @xml_element.get_elements(COMMAND_LINE_ARG_NODE).map { |argument| CommandLineArgument.new(argument) }
31
+ end
32
+
33
+ # Adds a given argument to the set of command line arguments, or replaces it if that key already exists
34
+ #
35
+ # @param [CommandLineArgument,Hash{Symbol => String,Bool}] argument
36
+ # The argument to add or update, backed by an CommandLineArgument node.
37
+ # - If an CommandLineArgument, the previous reference will still be valid
38
+ # - If a Hash, must conform to {CommandLineArgument#initialize} requirements
39
+ # @return [Array<CommandLineArgument>]
40
+ # The new set of command line arguments after addition
41
+ #
42
+ def assign_argument(argument)
43
+ command_line_arg = if argument.is_a?(CommandLineArgument)
44
+ argument
45
+ else
46
+ CommandLineArgument.new(argument)
47
+ end
48
+ all_arguments.each { |existing_var| remove_argument(existing_var) if existing_var.argument == command_line_arg.argument }
49
+ @xml_element.add_element(command_line_arg.xml_element)
50
+ @all_arguments << command_line_arg
51
+ end
52
+
53
+ # Removes a specified argument (by string or object) from the set of command line arguments
54
+ #
55
+ # @param [CommandLineArgument,String] argument
56
+ # The argument to remove
57
+ # @return [Array<CommandLineArgument>]
58
+ # The new set of command line arguments after removal
59
+ #
60
+ def remove_argument(argument)
61
+ command_line_arg = if argument.is_a?(CommandLineArgument)
62
+ argument
63
+ else
64
+ CommandLineArgument.new(argument)
65
+ end
66
+ raise "Unexpected parameter type: #{command_line_arg.class}" unless command_line_arg.is_a?(CommandLineArgument)
67
+ @xml_element.delete_element(command_line_arg.xml_element)
68
+ @all_arguments -= [command_line_arg]
69
+ end
70
+
71
+ # @param [String] key
72
+ # The key to lookup
73
+ # @return [CommandLineArgument] argument
74
+ # Returns the matching command line argument for a specified key
75
+ #
76
+ def [](argument)
77
+ all_arguments.find { |var| var.argument == argument }
78
+ end
79
+
80
+ # Assigns a value for a specified key
81
+ #
82
+ # @param [String] key
83
+ # The key to update in the command line arguments
84
+ # @param [String] value
85
+ # The value to lookup
86
+ # @return [CommandLineArgument] argument
87
+ # The newly updated command line argument
88
+ #
89
+ def []=(argument, enabled)
90
+ assign_argument(:argument => argument, :enabled => enabled)
91
+ self[argument]
92
+ end
93
+
94
+ # @return [Array<Hash{Symbol => String,Bool}>]
95
+ # The current command line arguments represented as an array
96
+ #
97
+ def to_a
98
+ all_arguments.map(&:to_h)
99
+ end
100
+ end
101
+
102
+ # This class wraps the CommandLineArgument node of a .xcscheme XML file.
103
+ # Environment arguments are accessible via the NSDictionary returned from
104
+ # [[NSProcessInfo processInfo] arguments] in your app code.
105
+ #
106
+ class CommandLineArgument < XMLElementWrapper
107
+ # @param [nil,REXML::Element,Hash{Symbol => String,Bool}] node_or_argument
108
+ # - If nil, it will create a default XML node to use
109
+ # - If a REXML::Element, should be a <CommandLineArgument> XML node to wrap
110
+ # - If a Hash, must contain keys :key and :value (Strings) and optionally :enabled (Boolean)
111
+ #
112
+ def initialize(node_or_argument)
113
+ create_xml_element_with_fallback(node_or_argument, COMMAND_LINE_ARG_NODE) do
114
+ raise "Must pass a Hash with 'argument' and 'enabled'!" unless node_or_argument.is_a?(Hash) &&
115
+ node_or_argument.key?(:argument) && node_or_argument.key?(:enabled)
116
+
117
+ @xml_element.attributes['argument'] = node_or_argument[:argument]
118
+ @xml_element.attributes['isEnabled'] = if node_or_argument.key?(:enabled)
119
+ bool_to_string(node_or_argument[:enabled])
120
+ else
121
+ bool_to_string(false)
122
+ end
123
+ end
124
+ end
125
+
126
+ # Returns the CommandLineArgument's key
127
+ # @return [String]
128
+ #
129
+ def argument
130
+ @xml_element.attributes['argument']
131
+ end
132
+
133
+ # Sets the CommandLineArgument's key
134
+ # @param [String] key
135
+ #
136
+ def argument=(argument)
137
+ @xml_element.attributes['argument'] = argument
138
+ end
139
+
140
+ # Returns the CommandLineArgument's enabled state
141
+ # @return [Bool]
142
+ #
143
+ def enabled
144
+ string_to_bool(@xml_element.attributes['isEnabled'])
145
+ end
146
+
147
+ # Sets the CommandLineArgument's enabled state
148
+ # @param [Bool] enabled
149
+ #
150
+ def enabled=(enabled)
151
+ @xml_element.attributes['isEnabled'] = bool_to_string(enabled)
152
+ end
153
+
154
+ # @return [Hash{:key => String, :value => String, :enabled => Bool}]
155
+ # The command line argument XML node with attributes converted to a representative Hash
156
+ #
157
+ def to_h
158
+ { :argument => argument, :enabled => enabled }
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,170 @@
1
+ require 'xcodeproj/scheme/xml_element_wrapper'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ VARIABLES_NODE = 'EnvironmentVariables'
6
+ VARIABLE_NODE = 'EnvironmentVariable'
7
+
8
+ # This class wraps the EnvironmentVariables node of a .xcscheme XML file. This
9
+ # is just a container of EnvironmentVariable objects. It can either appear on a
10
+ # LaunchAction or TestAction scheme group.
11
+ #
12
+ class EnvironmentVariables < XMLElementWrapper
13
+ # @param [nil,REXML::Element,Array<EnvironmentVariable>,Array<Hash{Symbol => String,Bool}>] node_or_variables
14
+ # The 'EnvironmentVariables' XML node, or list of environment variables, that this object represents.
15
+ # - If nil, an empty 'EnvironmentVariables' XML node will be created
16
+ # - If an REXML::Element, it must be named 'EnvironmentVariables'
17
+ # - If an Array of objects or Hashes, they'll each be passed to {#assign_variable}
18
+ #
19
+ def initialize(node_or_variables = nil)
20
+ create_xml_element_with_fallback(node_or_variables, VARIABLES_NODE) do
21
+ @all_variables = []
22
+ node_or_variables.each { |var| assign_variable(var) } unless node_or_variables.nil?
23
+ end
24
+ end
25
+
26
+ # @return [Array<EnvironmentVariable>]
27
+ # The key value pairs currently set in @xml_element
28
+ #
29
+ def all_variables
30
+ @all_variables ||= @xml_element.get_elements(VARIABLE_NODE).map { |variable| EnvironmentVariable.new(variable) }
31
+ end
32
+
33
+ # Adds a given variable to the set of environment variables, or replaces it if that key already exists
34
+ #
35
+ # @param [EnvironmentVariable,Hash{Symbol => String,Bool}] variable
36
+ # The variable to add or update, backed by an EnvironmentVariable node.
37
+ # - If an EnvironmentVariable, the previous reference will still be valid
38
+ # - If a Hash, must conform to {EnvironmentVariable#initialize} requirements
39
+ # @return [Array<EnvironmentVariable>]
40
+ # The new set of environment variables after addition
41
+ #
42
+ def assign_variable(variable)
43
+ env_var = variable.is_a?(EnvironmentVariable) ? variable : EnvironmentVariable.new(variable)
44
+ all_variables.each { |existing_var| remove_variable(existing_var) if existing_var.key == env_var.key }
45
+ @xml_element.add_element(env_var.xml_element)
46
+ @all_variables << env_var
47
+ end
48
+
49
+ # Removes a specified variable (by string or object) from the set of environment variables
50
+ #
51
+ # @param [EnvironmentVariable,String] variable
52
+ # The variable to remove
53
+ # @return [Array<EnvironmentVariable>]
54
+ # The new set of environment variables after removal
55
+ #
56
+ def remove_variable(variable)
57
+ env_var = variable.is_a?(EnvironmentVariable) ? variable : all_variables.find { |var| var.key == variable }
58
+ raise "Unexpected parameter type: #{env_var.class}" unless env_var.is_a?(EnvironmentVariable)
59
+ @xml_element.delete_element(env_var.xml_element)
60
+ @all_variables -= [env_var]
61
+ end
62
+
63
+ # @param [String] key
64
+ # The key to lookup
65
+ # @return [EnvironmentVariable] variable
66
+ # Returns the matching environment variable for a specified key
67
+ #
68
+ def [](key)
69
+ all_variables.find { |var| var.key == key }
70
+ end
71
+
72
+ # Assigns a value for a specified key
73
+ #
74
+ # @param [String] key
75
+ # The key to update in the environment variables
76
+ # @param [String] value
77
+ # The value to lookup
78
+ # @return [EnvironmentVariable] variable
79
+ # The newly updated environment variable
80
+ #
81
+ def []=(key, value)
82
+ assign_variable(:key => key, :value => value)
83
+ self[key]
84
+ end
85
+
86
+ # @return [Array<Hash{Symbol => String,Bool}>]
87
+ # The current environment variables represented as an array
88
+ #
89
+ def to_a
90
+ all_variables.map(&:to_h)
91
+ end
92
+ end
93
+
94
+ # This class wraps the EnvironmentVariable node of a .xcscheme XML file.
95
+ # Environment variables are accessible via the NSDictionary returned from
96
+ # [[NSProcessInfo processInfo] environment] in your app code.
97
+ #
98
+ class EnvironmentVariable < XMLElementWrapper
99
+ # @param [nil,REXML::Element,Hash{Symbol => String,Bool}] node_or_variable
100
+ # - If nil, it will create a default XML node to use
101
+ # - If a REXML::Element, should be a <EnvironmentVariable> XML node to wrap
102
+ # - If a Hash, must contain keys :key and :value (Strings) and optionally :enabled (Boolean)
103
+ #
104
+ def initialize(node_or_variable)
105
+ create_xml_element_with_fallback(node_or_variable, VARIABLE_NODE) do
106
+ raise "Must pass a Hash with 'key' and 'value'!" unless node_or_variable.is_a?(Hash) &&
107
+ node_or_variable.key?(:key) && node_or_variable.key?(:value)
108
+
109
+ @xml_element.attributes['key'] = node_or_variable[:key]
110
+ @xml_element.attributes['value'] = node_or_variable[:value]
111
+
112
+ @xml_element.attributes['isEnabled'] = if node_or_variable.key?(:enabled)
113
+ bool_to_string(node_or_variable[:enabled])
114
+ else
115
+ bool_to_string(true)
116
+ end
117
+ end
118
+ end
119
+
120
+ # Returns the EnvironmentValue's key
121
+ # @return [String]
122
+ #
123
+ def key
124
+ @xml_element.attributes['key']
125
+ end
126
+
127
+ # Sets the EnvironmentValue's key
128
+ # @param [String] key
129
+ #
130
+ def key=(key)
131
+ @xml_element.attributes['key'] = key
132
+ end
133
+
134
+ # Returns the EnvironmentValue's value
135
+ # @return [String]
136
+ #
137
+ def value
138
+ @xml_element.attributes['value']
139
+ end
140
+
141
+ # Sets the EnvironmentValue's value
142
+ # @param [String] value
143
+ #
144
+ def value=(value)
145
+ @xml_element.attributes['value'] = value
146
+ end
147
+
148
+ # Returns the EnvironmentValue's enabled state
149
+ # @return [Bool]
150
+ #
151
+ def enabled
152
+ string_to_bool(@xml_element.attributes['isEnabled'])
153
+ end
154
+
155
+ # Sets the EnvironmentValue's enabled state
156
+ # @param [Bool] enabled
157
+ #
158
+ def enabled=(enabled)
159
+ @xml_element.attributes['isEnabled'] = bool_to_string(enabled)
160
+ end
161
+
162
+ # @return [Hash{:key => String, :value => String, :enabled => Bool}]
163
+ # The environment variable XML node with attributes converted to a representative Hash
164
+ #
165
+ def to_h
166
+ { :key => key, :value => value, :enabled => enabled }
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,86 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # This class wraps the ExecutionAction node of a .xcscheme XML file
4
+ #
5
+ class ExecutionAction < XMLElementWrapper
6
+ # @param [REXML::Element] node
7
+ # The 'ExecutionAction' XML node that this object will wrap.
8
+ # If nil, will create an empty one
9
+ #
10
+ # @param [Symbol] action_type
11
+ # One of `EXECUTION_ACTION_TYPE.keys`
12
+ #
13
+ def initialize(node = nil, action_type = nil)
14
+ create_xml_element_with_fallback(node, 'ExecutionAction') do
15
+ type = action_type || node.action_type
16
+ raise "[Xcodeproj] Invalid ActionType `#{type}`" unless Constants::EXECUTION_ACTION_TYPE.keys.include?(type)
17
+ @xml_element.attributes['ActionType'] = Constants::EXECUTION_ACTION_TYPE[type]
18
+ end
19
+ end
20
+
21
+ # @return [String]
22
+ # The ActionType of this ExecutionAction. One of two values:
23
+ #
24
+ # Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction,
25
+ # Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.SendEmailAction
26
+ #
27
+ def action_type
28
+ @xml_element.attributes['ActionType']
29
+ end
30
+
31
+ # @return [ShellScriptActionContent]
32
+ # If action_type is 'Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction'
33
+ # returns the contents of the shell script to run pre/post action.
34
+ #
35
+ # @return [SendEmailActionContent]
36
+ # If action_type is 'Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.SendEmailAction'
37
+ # returns the contents of the email to send pre/post action.
38
+ #
39
+ def action_content
40
+ case action_type
41
+ when Constants::EXECUTION_ACTION_TYPE[:shell_script]
42
+ ShellScriptActionContent.new(@xml_element.elements['ActionContent'])
43
+ when Constants::EXECUTION_ACTION_TYPE[:send_email]
44
+ SendEmailActionContent.new(@xml_element.elements['ActionContent'])
45
+ else
46
+ raise "[Xcodeproj] Invalid ActionType `#{action_type}`"
47
+ end
48
+ end
49
+
50
+ # @param [ShellScriptActionContent, SendEmailActionContent] value
51
+ # Set either the contents of the shell script to run pre/post action
52
+ # or the contents of the email to send pre/post action.
53
+ #
54
+ def action_content=(value)
55
+ raise "[Xcodeproj] Invalid ActionContent `#{value.class}` for " \
56
+ "ActionType `#{action_type}`" unless valid_action_content?(value)
57
+
58
+ @xml_element.delete_element('ActionContent')
59
+ @xml_element.add_element(value.xml_element)
60
+ end
61
+
62
+ #-------------------------------------------------------------------------#
63
+
64
+ private
65
+
66
+ # @!group Private helpers
67
+
68
+ # @return [Bool]
69
+ # True if value (ActionContent) is valid for current action_type
70
+ #
71
+ # @param [ShellScriptActionContent, SendEmailActionContent] value
72
+ # Checks if value matches the expected action_type if present.
73
+ #
74
+ def valid_action_content?(value)
75
+ case action_type
76
+ when Constants::EXECUTION_ACTION_TYPE[:shell_script]
77
+ value.is_a?(ShellScriptActionContent)
78
+ when Constants::EXECUTION_ACTION_TYPE[:send_email]
79
+ value.is_a?(SendEmailActionContent)
80
+ else
81
+ false
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,179 @@
1
+ require 'xcodeproj/scheme/abstract_scheme_action'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the LaunchAction node of a .xcscheme XML file
6
+ #
7
+ class LaunchAction < AbstractSchemeAction
8
+ # @param [REXML::Element] node
9
+ # The 'LaunchAction' XML node that this object will wrap.
10
+ # If nil, will create a default XML node to use.
11
+ #
12
+ def initialize(node = nil)
13
+ create_xml_element_with_fallback(node, 'LaunchAction') do
14
+ self.build_configuration = 'Debug'
15
+
16
+ # Add some attributes (that are not handled by this wrapper class yet but expected in the XML)
17
+ @xml_element.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
18
+ @xml_element.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
19
+ @xml_element.attributes['launchStyle'] = '0'
20
+ @xml_element.attributes['useCustomWorkingDirectory'] = bool_to_string(false)
21
+ @xml_element.attributes['ignoresPersistentStateOnLaunch'] = bool_to_string(false)
22
+ @xml_element.attributes['debugDocumentVersioning'] = bool_to_string(true)
23
+ @xml_element.attributes['debugServiceExtension'] = 'internal'
24
+
25
+ # Setup default values for other (handled) attributes
26
+ self.allow_location_simulation = true
27
+ end
28
+ end
29
+
30
+ # @todo handle 'launchStyle' attribute
31
+ # @todo handle 'useCustomWorkingDirectory attribute
32
+ # @todo handle 'ignoresPersistentStateOnLaunch' attribute
33
+ # @todo handle 'debugDocumentVersioning' attribute
34
+ # @todo handle 'debugServiceExtension'
35
+
36
+ # @return [Bool]
37
+ # Whether or not to allow GPS location simulation when launching this target
38
+ #
39
+ def allow_location_simulation?
40
+ string_to_bool(@xml_element.attributes['allowLocationSimulation'])
41
+ end
42
+
43
+ # @param [Bool] flag
44
+ # Set whether or not to allow GPS location simulation when launching this target
45
+ #
46
+ def allow_location_simulation=(flag)
47
+ @xml_element.attributes['allowLocationSimulation'] = bool_to_string(flag)
48
+ end
49
+
50
+ # @return [LocationScenarioReference]
51
+ # The LocationScenarioReference to simulate a GPS location when executing the Launch Action
52
+ #
53
+ def location_scenario_reference?
54
+ LocationScenarioReference.new(@xml_element.elements['LocationScenarioReference'])
55
+ end
56
+
57
+ # @return [LocationScenarioReference]
58
+ # Set the LocationScenarioReference which simulates a GPS location when executing the Launch Action
59
+ #
60
+ def location_scenario_reference=(reference)
61
+ @xml_element.delete_element('LocationScenarioReference')
62
+ @xml_element.add_element(reference.xml_element) if reference
63
+ end
64
+
65
+ # @return [Bool]
66
+ # Whether this Build Action should disable detection of UI API misuse
67
+ # from background threads
68
+ #
69
+ def disable_main_thread_checker?
70
+ string_to_bool(@xml_element.attributes['disableMainThreadChecker'])
71
+ end
72
+
73
+ # @param [Bool] flag
74
+ # Set whether this Build Action should disable detection of UI API misuse
75
+ # from background threads
76
+ #
77
+ def disable_main_thread_checker=(flag)
78
+ @xml_element.attributes['disableMainThreadChecker'] = bool_to_string(flag)
79
+ end
80
+
81
+ # @return [Bool]
82
+ # Whether UI API misuse from background threads detection should pause execution.
83
+ # This flag is ignored when the thread checker disabled
84
+ # ([disable_main_thread_checker] flag).
85
+ #
86
+ def stop_on_every_main_thread_checker_issue?
87
+ string_to_bool(@xml_element.attributes['stopOnEveryMainThreadCheckerIssue'])
88
+ end
89
+
90
+ # @param [Bool] flag
91
+ # Set whether UI API misuse from background threads detection should pause execution.
92
+ # This flag is ignored when the thread checker disabled
93
+ # ([disable_main_thread_checker] flag).
94
+ #
95
+ def stop_on_every_main_thread_checker_issue=(flag)
96
+ @xml_element.attributes['stopOnEveryMainThreadCheckerIssue'] = bool_to_string(flag)
97
+ end
98
+
99
+ # @return [String]
100
+ # The launch automatically substyle
101
+ #
102
+ def launch_automatically_substyle
103
+ @xml_element.attributes['launchAutomaticallySubstyle']
104
+ end
105
+
106
+ # @param [String] flag
107
+ # Set the launch automatically substyle ('2' for extensions)
108
+ #
109
+ def launch_automatically_substyle=(value)
110
+ @xml_element.attributes['launchAutomaticallySubstyle'] = value.to_s
111
+ end
112
+
113
+ # @return [BuildableProductRunnable]
114
+ # The BuildReference to launch when executing the Launch Action
115
+ #
116
+ def buildable_product_runnable
117
+ BuildableProductRunnable.new(@xml_element.elements['BuildableProductRunnable'], 0)
118
+ end
119
+
120
+ # @param [BuildableProductRunnable] runnable
121
+ # Set the BuildableProductRunnable referencing the target to launch
122
+ #
123
+ def buildable_product_runnable=(runnable)
124
+ @xml_element.delete_element('BuildableProductRunnable')
125
+ @xml_element.add_element(runnable.xml_element) if runnable
126
+ end
127
+
128
+ # @return [EnvironmentVariables]
129
+ # Returns the EnvironmentVariables that will be defined at app launch
130
+ #
131
+ def environment_variables
132
+ EnvironmentVariables.new(@xml_element.elements[XCScheme::VARIABLES_NODE])
133
+ end
134
+
135
+ # @param [EnvironmentVariables,nil] env_vars
136
+ # Sets the EnvironmentVariables that will be defined at app launch
137
+ #
138
+ def environment_variables=(env_vars)
139
+ @xml_element.delete_element(XCScheme::VARIABLES_NODE)
140
+ @xml_element.add_element(env_vars.xml_element) if env_vars
141
+ env_vars
142
+ end
143
+
144
+ # @todo handle 'AdditionalOptions' tag
145
+
146
+ # @return [CommandLineArguments]
147
+ # Returns the CommandLineArguments that will be passed at app launch
148
+ #
149
+ def command_line_arguments
150
+ CommandLineArguments.new(@xml_element.elements[XCScheme::COMMAND_LINE_ARGS_NODE])
151
+ end
152
+
153
+ # @return [CommandLineArguments] arguments
154
+ # Sets the CommandLineArguments that will be passed at app launch
155
+ #
156
+ def command_line_arguments=(arguments)
157
+ @xml_element.delete_element(XCScheme::COMMAND_LINE_ARGS_NODE)
158
+ @xml_element.add_element(arguments.xml_element) if arguments
159
+ arguments
160
+ end
161
+
162
+ # @return [Array<MacroExpansion>]
163
+ # The list of MacroExpansion bound with this LaunchAction
164
+ #
165
+ def macro_expansions
166
+ @xml_element.get_elements('MacroExpansion').map do |node|
167
+ MacroExpansion.new(node)
168
+ end
169
+ end
170
+
171
+ # @param [MacroExpansion] macro_expansion
172
+ # Add a MacroExpansion to this LaunchAction
173
+ #
174
+ def add_macro_expansion(macro_expansion)
175
+ @xml_element.add_element(macro_expansion.xml_element)
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,49 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # This class wraps the LocationScenarioReference node of a .xcscheme XML file
4
+ #
5
+ # A LocationScenarioReference is a reference to a simulated GPS location associated
6
+ # with a scheme's launch action
7
+ #
8
+ class LocationScenarioReference < XMLElementWrapper
9
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
10
+ # Either the Xcode target to reference,
11
+ # or an existing XML 'LocationScenarioReference' node element to reference
12
+ #
13
+ def initialize(target_or_node)
14
+ create_xml_element_with_fallback(target_or_node, 'LocationScenarioReference') do
15
+ self.identifier = ''
16
+ self.reference_type = '0'
17
+ end
18
+ end
19
+
20
+ # @return [String]
21
+ # The identifier of a built-in location scenario reference, or a path to a GPX file
22
+ #
23
+ def identifier
24
+ @xml_element.attributes['identifier']
25
+ end
26
+
27
+ # @param [String] value
28
+ # Set the identifier for the location scenario reference
29
+ #
30
+ def identifier=(value)
31
+ @xml_element.attributes['identifier'] = value
32
+ end
33
+
34
+ # @return [String]
35
+ # The reference type is 0 when using a custom GPX file, or 1 when using a built-in location reference
36
+ #
37
+ def reference_type
38
+ @xml_element.attributes['referenceType']
39
+ end
40
+
41
+ # @param [String] value
42
+ # Set the reference type for the location scenario reference
43
+ #
44
+ def reference_type=(value)
45
+ @xml_element.attributes['referenceType'] = value
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,34 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # This class wraps the MacroExpansion node of a .xcscheme XML file
4
+ #
5
+ class MacroExpansion < XMLElementWrapper
6
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
7
+ # Either the Xcode target to reference,
8
+ # or an existing XML 'MacroExpansion' node element
9
+ # or nil to create an empty MacroExpansion object
10
+ #
11
+ def initialize(target_or_node = nil)
12
+ create_xml_element_with_fallback(target_or_node, 'MacroExpansion') do
13
+ self.buildable_reference = BuildableReference.new(target_or_node) if target_or_node
14
+ end
15
+ end
16
+
17
+ # @return [BuildableReference]
18
+ # The BuildableReference this MacroExpansion refers to
19
+ #
20
+ def buildable_reference
21
+ @buildable_reference ||= BuildableReference.new @xml_element.elements['BuildableReference']
22
+ end
23
+
24
+ # @param [BuildableReference] ref
25
+ # Set the BuildableReference this MacroExpansion refers to
26
+ #
27
+ def buildable_reference=(ref)
28
+ @xml_element.delete_element('BuildableReference')
29
+ @xml_element.add_element(ref.xml_element)
30
+ @buildable_reference = ref
31
+ end
32
+ end
33
+ end
34
+ end