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,100 @@
1
+ require 'xcodeproj/scheme/xml_element_wrapper'
2
+ require 'xcodeproj/scheme/environment_variables'
3
+ require 'xcodeproj/scheme/command_line_arguments'
4
+
5
+ module Xcodeproj
6
+ class XCScheme
7
+ # This abstract class aims to be the base class for every XxxAction class
8
+ # that have a #build_configuration attribute
9
+ #
10
+ class AbstractSchemeAction < XMLElementWrapper
11
+ # @return [String]
12
+ # The build configuration associated with this action
13
+ # (usually either 'Debug' or 'Release')
14
+ #
15
+ def build_configuration
16
+ @xml_element.attributes['buildConfiguration']
17
+ end
18
+
19
+ # @param [String] config_name
20
+ # The build configuration to associate with this action
21
+ # (usually either 'Debug' or 'Release')
22
+ #
23
+ def build_configuration=(config_name)
24
+ @xml_element.attributes['buildConfiguration'] = config_name
25
+ end
26
+
27
+ # @return [Array<ExecutionAction>]
28
+ # The list of actions to run before this scheme action.
29
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
30
+ #
31
+ def pre_actions
32
+ pre_actions = @xml_element.elements['PreActions']
33
+ return nil unless pre_actions
34
+ pre_actions.get_elements('ExecutionAction').map do |entry_node|
35
+ ExecutionAction.new(entry_node)
36
+ end
37
+ end
38
+
39
+ # @param [Array<ExecutionAction>] pre_actions
40
+ # Set the list of actions to run before this scheme action.
41
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
42
+ #
43
+ def pre_actions=(pre_actions)
44
+ @xml_element.delete_element('PreActions')
45
+ unless pre_actions.empty?
46
+ pre_actions_element = @xml_element.add_element('PreActions')
47
+ pre_actions.each do |entry_node|
48
+ pre_actions_element.add_element(entry_node.xml_element)
49
+ end
50
+ end
51
+ pre_actions
52
+ end
53
+
54
+ # @param [ExecutionAction] pre_action
55
+ # Add an action to the list of actions to run before this scheme action.
56
+ # It can be either a 'Run Script' or a 'Send Email' action.
57
+ #
58
+ def add_pre_action(pre_action)
59
+ pre_actions = @xml_element.elements['PreActions'] || @xml_element.add_element('PreActions')
60
+ pre_actions.add_element(pre_action.xml_element)
61
+ end
62
+
63
+ # @return [Array<ExecutionAction>]
64
+ # The list of actions to run after this scheme action.
65
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
66
+ #
67
+ def post_actions
68
+ post_actions = @xml_element.elements['PostActions']
69
+ return nil unless post_actions
70
+ post_actions.get_elements('ExecutionAction').map do |entry_node|
71
+ ExecutionAction.new(entry_node)
72
+ end
73
+ end
74
+
75
+ # @param [Array<ExecutionAction>] post_actions
76
+ # Set the list of actions to run after this scheme action.
77
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
78
+ #
79
+ def post_actions=(post_actions)
80
+ @xml_element.delete_element('PostActions')
81
+ unless post_actions.empty?
82
+ post_actions_element = @xml_element.add_element('PostActions')
83
+ post_actions.each do |entry_node|
84
+ post_actions_element.add_element(entry_node.xml_element)
85
+ end
86
+ end
87
+ post_actions
88
+ end
89
+
90
+ # @param [ExecutionAction] post_action
91
+ # Add an action to the list of actions to run after this scheme action.
92
+ # It can be either a 'Run Script' or a 'Send Email' action.
93
+ #
94
+ def add_post_action(post_action)
95
+ post_actions = @xml_element.elements['PostActions'] || @xml_element.add_element('PostActions')
96
+ post_actions.add_element(post_action.xml_element)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,19 @@
1
+ require 'xcodeproj/scheme/abstract_scheme_action'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the AnalyzeAction node of a .xcscheme XML file
6
+ #
7
+ class AnalyzeAction < AbstractSchemeAction
8
+ # @param [REXML::Element] node
9
+ # The 'AnalyzeAction' 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, 'AnalyzeAction') do
14
+ self.build_configuration = 'Debug'
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ require 'xcodeproj/scheme/abstract_scheme_action'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the ArchiveAction node of a .xcscheme XML file
6
+ #
7
+ class ArchiveAction < AbstractSchemeAction
8
+ # @param [REXML::Element] node
9
+ # The 'ArchiveAction' 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, 'ArchiveAction') do
14
+ self.build_configuration = 'Release'
15
+ self.reveal_archive_in_organizer = true
16
+ end
17
+ end
18
+
19
+ # @return [Bool]
20
+ # Whether the Archive will be revealed in Xcode's Organizer
21
+ # after it's done building.
22
+ #
23
+ def reveal_archive_in_organizer?
24
+ string_to_bool(@xml_element.attributes['revealArchiveInOrganizer'])
25
+ end
26
+
27
+ # @param [Bool] flag
28
+ # Set whether the Archive will be revealed in Xcode's Organizer
29
+ # after it's done building.
30
+ #
31
+ def reveal_archive_in_organizer=(flag)
32
+ @xml_element.attributes['revealArchiveInOrganizer'] = bool_to_string(flag)
33
+ end
34
+
35
+ # @return [String]
36
+ # The custom name to give to the archive.
37
+ # If nil, the generated archive will have the same name as the one
38
+ # set in the associated target's Build Settings for the built product.
39
+ #
40
+ def custom_archive_name
41
+ @xml_element.attributes['customArchiveName']
42
+ end
43
+
44
+ # @param [String] name
45
+ # Set the custom name to use for the built archive
46
+ # If nil, the customization of the archive name will be removed and
47
+ # the generated archive will have the same name as the one set in the
48
+ # associated target's Build Settings for the build product.
49
+ #
50
+ def custom_archive_name=(name)
51
+ if name
52
+ @xml_element.attributes['customArchiveName'] = name
53
+ else
54
+ @xml_element.delete_attribute('customArchiveName')
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,298 @@
1
+ require 'xcodeproj/scheme/xml_element_wrapper'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the BuildAction node of a .xcscheme XML file
6
+ #
7
+ # Note: It's not a AbstractSchemeAction like the others because it is
8
+ # a special case of action (with no build_configuration, etc)
9
+ #
10
+ class BuildAction < XMLElementWrapper
11
+ # @param [REXML::Element] node
12
+ # The 'BuildAction' XML node that this object will wrap.
13
+ # If nil, will create a default XML node to use.
14
+ #
15
+ def initialize(node = nil)
16
+ create_xml_element_with_fallback(node, 'BuildAction') do
17
+ self.parallelize_buildables = true
18
+ self.build_implicit_dependencies = true
19
+ end
20
+ end
21
+
22
+ # @return [Bool]
23
+ # Whether or not to run post actions on build failure
24
+ #
25
+ def run_post_actions_on_failure?
26
+ string_to_bool(@xml_element.attributes['runPostActionsOnFailure'])
27
+ end
28
+
29
+ # @param [Bool] flag
30
+ # Set whether or not to run post actions on build failure
31
+ #
32
+ def run_post_actions_on_failure=(flag)
33
+ @xml_element.attributes['runPostActionsOnFailure'] = bool_to_string(flag)
34
+ end
35
+
36
+ # @return [Bool]
37
+ # Whether or not to build the various targets in parallel
38
+ #
39
+ def parallelize_buildables?
40
+ string_to_bool(@xml_element.attributes['parallelizeBuildables'])
41
+ end
42
+
43
+ # @param [Bool] flag
44
+ # Set whether or not to build the various targets in parallel
45
+ #
46
+ def parallelize_buildables=(flag)
47
+ @xml_element.attributes['parallelizeBuildables'] = bool_to_string(flag)
48
+ end
49
+
50
+ # @return [Bool]
51
+ # Whether or not to detect and build implicit dependencies for each target
52
+ #
53
+ def build_implicit_dependencies?
54
+ string_to_bool(@xml_element.attributes['buildImplicitDependencies'])
55
+ end
56
+
57
+ # @param [Bool] flag
58
+ # Whether or not to detect and build implicit dependencies for each target
59
+ #
60
+ def build_implicit_dependencies=(flag)
61
+ @xml_element.attributes['buildImplicitDependencies'] = bool_to_string(flag)
62
+ end
63
+
64
+ # @return [Array<ExecutionAction>]
65
+ # The list of actions to run before this scheme action.
66
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
67
+ #
68
+ def pre_actions
69
+ pre_actions = @xml_element.elements['PreActions']
70
+ return nil unless pre_actions
71
+ pre_actions.get_elements('ExecutionAction').map do |entry_node|
72
+ ExecutionAction.new(entry_node)
73
+ end
74
+ end
75
+
76
+ # @param [Array<ExecutionAction>] pre_actions
77
+ # Set the list of actions to run before this scheme action.
78
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
79
+ #
80
+ def pre_actions=(pre_actions)
81
+ @xml_element.delete_element('PreActions')
82
+ unless pre_actions.empty?
83
+ pre_actions_element = @xml_element.add_element('PreActions')
84
+ pre_actions.each do |entry_node|
85
+ pre_actions_element.add_element(entry_node.xml_element)
86
+ end
87
+ end
88
+ pre_actions
89
+ end
90
+
91
+ # @param [ExecutionAction] pre_action
92
+ # Add an action to the list of actions to run before this scheme action.
93
+ # It can be either a 'Run Script' or a 'Send Email' action.
94
+ #
95
+ def add_pre_action(pre_action)
96
+ pre_actions = @xml_element.elements['PreActions'] || @xml_element.add_element('PreActions')
97
+ pre_actions.add_element(pre_action.xml_element)
98
+ end
99
+
100
+ # @return [Array<ExecutionAction>]
101
+ # The list of actions to run after this scheme action.
102
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
103
+ #
104
+ def post_actions
105
+ post_actions = @xml_element.elements['PostActions']
106
+ return nil unless post_actions
107
+ post_actions.get_elements('ExecutionAction').map do |entry_node|
108
+ ExecutionAction.new(entry_node)
109
+ end
110
+ end
111
+
112
+ # @param [Array<ExecutionAction>] post_actions
113
+ # Set the list of actions to run after this scheme action.
114
+ # Each entry can be either a 'Run Script' or a 'Send Email' action.
115
+ #
116
+ def post_actions=(post_actions)
117
+ @xml_element.delete_element('PostActions')
118
+ unless post_actions.empty?
119
+ post_actions_element = @xml_element.add_element('PostActions')
120
+ post_actions.each do |entry_node|
121
+ post_actions_element.add_element(entry_node.xml_element)
122
+ end
123
+ end
124
+ post_actions
125
+ end
126
+
127
+ # @param [ExecutionAction] post_action
128
+ # Add an action to the list of actions to run after this scheme action.
129
+ # It can be either a 'Run Script' or a 'Send Email' action.
130
+ #
131
+ def add_post_action(post_action)
132
+ post_actions = @xml_element.elements['PostActions'] || @xml_element.add_element('PostActions')
133
+ post_actions.add_element(post_action.xml_element)
134
+ end
135
+
136
+ # @return [Array<BuildAction::Entry>]
137
+ # The list of BuildActionEntry nodes associated with this Build Action.
138
+ # Each entry represent a target to build and tells for which action it's needed to be built.
139
+ #
140
+ def entries
141
+ entries = @xml_element.elements['BuildActionEntries']
142
+ return nil unless entries
143
+ entries.get_elements('BuildActionEntry').map do |entry_node|
144
+ BuildAction::Entry.new(entry_node)
145
+ end
146
+ end
147
+
148
+ # @param [Array<BuildAction::Entry>] entries
149
+ # Sets the list of BuildActionEntry nodes associated with this Build Action.
150
+ #
151
+ def entries=(entries)
152
+ @xml_element.delete_element('BuildActionEntries')
153
+ unless entries.empty?
154
+ entries_element = @xml_element.add_element('BuildActionEntries')
155
+ entries.each do |entry_node|
156
+ entries_element.add_element(entry_node.xml_element)
157
+ end
158
+ end
159
+ entries
160
+ end
161
+
162
+ # @param [BuildAction::Entry] entry
163
+ # The BuildActionEntry to add to the list of targets to build for the various actions
164
+ #
165
+ def add_entry(entry)
166
+ entries = @xml_element.elements['BuildActionEntries'] || @xml_element.add_element('BuildActionEntries')
167
+ entries.add_element(entry.xml_element)
168
+ end
169
+
170
+ #-------------------------------------------------------------------------#
171
+
172
+ class Entry < XMLElementWrapper
173
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
174
+ # Either the Xcode target to reference,
175
+ # or an existing XML 'BuildActionEntry' node element to reference,
176
+ # or nil to create an new, empty Entry with default values
177
+ #
178
+ def initialize(target_or_node = nil)
179
+ create_xml_element_with_fallback(target_or_node, 'BuildActionEntry') do
180
+ # Check target type to configure the default entry attributes accordingly
181
+ is_test_target = false
182
+ is_app_target = false
183
+ if target_or_node && target_or_node.is_a?(::Xcodeproj::Project::Object::PBXNativeTarget)
184
+ test_types = [Constants::PRODUCT_TYPE_UTI[:octest_bundle],
185
+ Constants::PRODUCT_TYPE_UTI[:unit_test_bundle],
186
+ Constants::PRODUCT_TYPE_UTI[:ui_test_bundle]]
187
+ app_types = [Constants::PRODUCT_TYPE_UTI[:application]]
188
+ is_test_target = test_types.include?(target_or_node.product_type)
189
+ is_app_target = app_types.include?(target_or_node.product_type)
190
+ end
191
+
192
+ self.build_for_testing = is_test_target
193
+ self.build_for_running = is_app_target
194
+ self.build_for_profiling = is_app_target
195
+ self.build_for_archiving = is_app_target
196
+ self.build_for_analyzing = true
197
+
198
+ add_buildable_reference BuildableReference.new(target_or_node) if target_or_node
199
+ end
200
+ end
201
+
202
+ # @return [Bool]
203
+ # Whether or not to build this target when building for Testing
204
+ #
205
+ def build_for_testing?
206
+ string_to_bool(@xml_element.attributes['buildForTesting'])
207
+ end
208
+
209
+ # @param [Bool]
210
+ # Set whether or not to build this target when building for Testing
211
+ #
212
+ def build_for_testing=(flag)
213
+ @xml_element.attributes['buildForTesting'] = bool_to_string(flag)
214
+ end
215
+
216
+ # @return [Bool]
217
+ # Whether or not to build this target when building for Running
218
+ #
219
+ def build_for_running?
220
+ string_to_bool(@xml_element.attributes['buildForRunning'])
221
+ end
222
+
223
+ # @param [Bool]
224
+ # Set whether or not to build this target when building for Running
225
+ #
226
+ def build_for_running=(flag)
227
+ @xml_element.attributes['buildForRunning'] = bool_to_string(flag)
228
+ end
229
+
230
+ # @return [Bool]
231
+ # Whether or not to build this target when building for Profiling
232
+ #
233
+ def build_for_profiling?
234
+ string_to_bool(@xml_element.attributes['buildForProfiling'])
235
+ end
236
+
237
+ # @param [Bool]
238
+ # Set whether or not to build this target when building for Profiling
239
+ #
240
+ def build_for_profiling=(flag)
241
+ @xml_element.attributes['buildForProfiling'] = bool_to_string(flag)
242
+ end
243
+
244
+ # @return [Bool]
245
+ # Whether or not to build this target when building for Archiving
246
+ #
247
+ def build_for_archiving?
248
+ string_to_bool(@xml_element.attributes['buildForArchiving'])
249
+ end
250
+
251
+ # @param [Bool]
252
+ # Set whether or not to build this target when building for Archiving
253
+ #
254
+ def build_for_archiving=(flag)
255
+ @xml_element.attributes['buildForArchiving'] = bool_to_string(flag)
256
+ end
257
+
258
+ # @return [Bool]
259
+ # Whether or not to build this target when building for Analyzing
260
+ #
261
+ def build_for_analyzing?
262
+ string_to_bool(@xml_element.attributes['buildForAnalyzing'])
263
+ end
264
+
265
+ # @param [Bool]
266
+ # Set whether or not to build this target when building for Analyzing
267
+ #
268
+ def build_for_analyzing=(flag)
269
+ @xml_element.attributes['buildForAnalyzing'] = bool_to_string(flag)
270
+ end
271
+
272
+ # @return [Array<BuildableReference>]
273
+ # The list of BuildableReferences this entry will build.
274
+ # (The list usually contains only one element)
275
+ #
276
+ def buildable_references
277
+ @xml_element.get_elements('BuildableReference').map do |node|
278
+ BuildableReference.new(node)
279
+ end
280
+ end
281
+
282
+ # @param [BuildableReference] ref
283
+ # The BuildableReference to add to the list of targets this entry will build
284
+ #
285
+ def add_buildable_reference(ref)
286
+ @xml_element.add_element(ref.xml_element)
287
+ end
288
+
289
+ # @param [BuildableReference] ref
290
+ # The BuildableReference to remove from the list of targets this entry will build
291
+ #
292
+ def remove_buildable_reference(ref)
293
+ @xml_element.delete_element(ref.xml_element)
294
+ end
295
+ end
296
+ end
297
+ end
298
+ end
@@ -0,0 +1,55 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # This class wraps the BuildableProductRunnable node of a .xcscheme XML file
4
+ #
5
+ # A BuildableProductRunnable is a product that is both buildable
6
+ # (it contains a BuildableReference) and runnable (it can be launched and debugged)
7
+ #
8
+ class BuildableProductRunnable < XMLElementWrapper
9
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
10
+ # Either the Xcode target to reference,
11
+ # or an existing XML 'BuildableProductRunnable' node element to reference
12
+ # or nil to create an new, empty BuildableProductRunnable
13
+ #
14
+ # @param [#to_s] runnable_debugging_mode
15
+ # The debugging mode (usually '0')
16
+ #
17
+ def initialize(target_or_node = nil, runnable_debugging_mode = nil)
18
+ create_xml_element_with_fallback(target_or_node, 'BuildableProductRunnable') do
19
+ self.buildable_reference = BuildableReference.new(target_or_node) if target_or_node
20
+ @xml_element.attributes['runnableDebuggingMode'] = runnable_debugging_mode.to_s if runnable_debugging_mode
21
+ end
22
+ end
23
+
24
+ # @return [String]
25
+ # The Runnable debugging mode (usually either empty or equal to '0')
26
+ #
27
+ def runnable_debugging_mode
28
+ @xml_element.attributes['runnableDebuggingMode']
29
+ end
30
+
31
+ # @param [String] value
32
+ # Set the runnable debugging mode of this buildable product runnable
33
+ #
34
+ def runnable_debugging_mode=(value)
35
+ @xml_element.attributes['runnableDebuggingMode'] = value.to_s
36
+ end
37
+
38
+ # @return [BuildableReference]
39
+ # The Buildable Reference this Buildable Product Runnable is gonna build and run
40
+ #
41
+ def buildable_reference
42
+ @buildable_reference ||= BuildableReference.new @xml_element.elements['BuildableReference']
43
+ end
44
+
45
+ # @param [BuildableReference] ref
46
+ # Set the Buildable Reference this Buildable Product Runnable is gonna build and run
47
+ #
48
+ def buildable_reference=(ref)
49
+ @xml_element.delete_element('BuildableReference')
50
+ @xml_element.add_element(ref.xml_element)
51
+ @buildable_reference = ref
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,129 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # This class wraps the BuildableReference node of a .xcscheme XML file
4
+ #
5
+ # A BuildableReference is a reference to a buildable product (which is
6
+ # typically is synonymous for an Xcode target)
7
+ #
8
+ class BuildableReference < XMLElementWrapper
9
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
10
+ # Either the Xcode target to reference,
11
+ # or an existing XML 'BuildableReference' node element to reference
12
+ #
13
+ # @param [Xcodeproj::Project] the root project to reference from
14
+ # (when nil the project of the target is used)
15
+ #
16
+ def initialize(target_or_node, root_project = nil)
17
+ create_xml_element_with_fallback(target_or_node, 'BuildableReference') do
18
+ @xml_element.attributes['BuildableIdentifier'] = 'primary'
19
+ set_reference_target(target_or_node, true, root_project) if target_or_node
20
+ end
21
+ end
22
+
23
+ # @return [String]
24
+ # The name of the target this Buildable Reference points to
25
+ #
26
+ def target_name
27
+ @xml_element.attributes['BlueprintName']
28
+ end
29
+
30
+ # @return [String]
31
+ # The Unique Identifier of the target (target.uuid) this Buildable Reference points to.
32
+ #
33
+ # @note You can use this to `#find` the `Xcodeproj::Project::Object::AbstractTarget`
34
+ # instance in your Xcodeproj::Project object.
35
+ # e.g. `project.targets.find { |t| t.uuid == ref.target_uuid }`
36
+ #
37
+ def target_uuid
38
+ @xml_element.attributes['BlueprintIdentifier']
39
+ end
40
+
41
+ # @return [String]
42
+ # The string representing the container of that target.
43
+ # Typically in the form of 'container:xxxx.xcodeproj'
44
+ #
45
+ def target_referenced_container
46
+ @xml_element.attributes['ReferencedContainer']
47
+ end
48
+
49
+ # Set the BlueprintIdentifier (target.uuid), BlueprintName (target.name)
50
+ # and TerefencedContainer (URI pointing to target's projet) all at once
51
+ #
52
+ # @param [Xcodeproj::Project::Object::AbstractTarget] target
53
+ # The target this BuildableReference refers to.
54
+ #
55
+ # @param [Xcodeproj::Project] the root project to reference from
56
+ # (when nil the project of the target is used)
57
+ #
58
+ # @param [Bool] override_buildable_name
59
+ # If true, buildable_name will also be updated by computing a name from the target
60
+ #
61
+ def set_reference_target(target, override_buildable_name = false, root_project = nil)
62
+ # note, the order of assignment here is important, it determines the order of serialization in the xml
63
+ # this matches the order that Xcode generates
64
+ @xml_element.attributes['BlueprintIdentifier'] = target.uuid
65
+ self.buildable_name = construct_buildable_name(target) if override_buildable_name
66
+ @xml_element.attributes['BlueprintName'] = target.name
67
+ @xml_element.attributes['ReferencedContainer'] = construct_referenced_container_uri(target, root_project)
68
+ end
69
+
70
+ # @return [String]
71
+ # The name of the final product when building this Buildable Reference
72
+ #
73
+ def buildable_name
74
+ @xml_element.attributes['BuildableName']
75
+ end
76
+
77
+ # @param [String] value
78
+ # Set the name of the final product when building this Buildable Reference
79
+ #
80
+ def buildable_name=(value)
81
+ @xml_element.attributes['BuildableName'] = value
82
+ end
83
+
84
+ #-------------------------------------------------------------------------#
85
+
86
+ private
87
+
88
+ # @!group Private helpers
89
+
90
+ # @param [Xcodeproj::Project::Object::AbstractTarget] target
91
+ #
92
+ # @return [String] The buildable name of the scheme.
93
+ #
94
+ def construct_buildable_name(build_target)
95
+ case build_target.isa
96
+ when 'PBXNativeTarget'
97
+ File.basename(build_target.product_reference.path)
98
+ when 'PBXAggregateTarget'
99
+ build_target.name
100
+ else
101
+ raise ArgumentError, "Unsupported build target type #{build_target.isa}"
102
+ end
103
+ end
104
+
105
+ # @param [Xcodeproj::Project::Object::AbstractTarget] target
106
+ #
107
+ # @param [Xcodeproj::Project] the root project to reference from
108
+ # (when nil the project of the target is used)
109
+ #
110
+ # @return [String] A string in the format "container:[path to the project
111
+ # file relative to the project_dir_path, always ending with
112
+ # the actual project directory name]"
113
+ #
114
+ def construct_referenced_container_uri(target, root_project = nil)
115
+ target_project = target.project
116
+ root_project ||= target_project
117
+ root_project_dir_path = root_project.root_object.project_dir_path
118
+ path = if !root_project_dir_path.to_s.empty?
119
+ root_project.path + root_project_dir_path
120
+ else
121
+ root_project.project_dir
122
+ end
123
+ relative_path = target_project.path.relative_path_from(path).to_s
124
+ relative_path = target_project.path.basename if relative_path == '.'
125
+ "container:#{relative_path}"
126
+ end
127
+ end
128
+ end
129
+ end