xcodeproj 0.26.3 → 0.27.0
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.
- checksums.yaml +4 -4
- data/lib/xcodeproj/config.rb +2 -1
- data/lib/xcodeproj/constants.rb +12 -5
- data/lib/xcodeproj/gem_version.rb +1 -1
- data/lib/xcodeproj/project/object.rb +1 -1
- data/lib/xcodeproj/project/object/group.rb +2 -2
- data/lib/xcodeproj/scheme.rb +174 -137
- data/lib/xcodeproj/scheme/abstract_scheme_action.rb +26 -0
- data/lib/xcodeproj/scheme/analyze_action.rb +19 -0
- data/lib/xcodeproj/scheme/archive_action.rb +59 -0
- data/lib/xcodeproj/scheme/build_action.rb +186 -0
- data/lib/xcodeproj/scheme/buildable_product_runnable.rb +55 -0
- data/lib/xcodeproj/scheme/buildable_reference.rb +111 -0
- data/lib/xcodeproj/scheme/launch_action.rb +68 -0
- data/lib/xcodeproj/scheme/macro_expansion.rb +34 -0
- data/lib/xcodeproj/scheme/profile_action.rb +57 -0
- data/lib/xcodeproj/scheme/test_action.rb +123 -0
- data/lib/xcodeproj/scheme/xml_element_wrapper.rb +82 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e0ee7bf2c3ae317b24d55195a21d22c9018a67
|
4
|
+
data.tar.gz: e07317fcef70ba2aa4969bbea76bda7c3a0f52ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3ed731a9be7088415abe1e113b7d7ec85113a735217063b41b38c7da5e8111701a86470843ae17df1f2529304706e7853b49b2fb73d3d5008aeb3586b67baf0
|
7
|
+
data.tar.gz: 88be395b0399c6bc5e879d9cb94cd9785b5efa8ee5545b13d83b3a435cd932f2367b35e7db6beb10fa4e80816895c781b1287b6d857301d99c4edf323ccc08a8
|
data/lib/xcodeproj/config.rb
CHANGED
@@ -81,7 +81,7 @@ module Xcodeproj
|
|
81
81
|
#
|
82
82
|
def to_s(prefix = nil)
|
83
83
|
include_lines = includes.map { |path| "#include \"#{normalized_xcconfig_path(path)}\"" }
|
84
|
-
settings = to_hash(prefix).sort_by(&:first).map { |k, v| "#{k} = #{v}" }
|
84
|
+
settings = to_hash(prefix).sort_by(&:first).map { |k, v| "#{k} = #{v}".strip }
|
85
85
|
[include_lines + settings].join("\n")
|
86
86
|
end
|
87
87
|
|
@@ -131,6 +131,7 @@ module Xcodeproj
|
|
131
131
|
|
132
132
|
result = attributes.dup
|
133
133
|
result['OTHER_LDFLAGS'] = list.join(' ') unless list.empty?
|
134
|
+
result.reject! { |_, v| %w($(inherited) ${inherited}).freeze.any? { |i| i == v.strip } }
|
134
135
|
|
135
136
|
if prefix
|
136
137
|
Hash[result.map { |k, v| [prefix + k, v] }]
|
data/lib/xcodeproj/constants.rb
CHANGED
@@ -32,6 +32,10 @@ module Xcodeproj
|
|
32
32
|
#
|
33
33
|
LAST_SWIFT_UPGRADE_CHECK = '0700'
|
34
34
|
|
35
|
+
# @return [String] The version of `.xcscheme` files supported by Xcodeproj
|
36
|
+
#
|
37
|
+
XCSCHEME_FORMAT_VERSION = '1.3'
|
38
|
+
|
35
39
|
# @return [Hash] The all the known ISAs grouped by superclass.
|
36
40
|
#
|
37
41
|
KNOWN_ISAS = {
|
@@ -104,6 +108,7 @@ module Xcodeproj
|
|
104
108
|
:dynamic_library => 'com.apple.product-type.library.dynamic',
|
105
109
|
:static_library => 'com.apple.product-type.library.static',
|
106
110
|
:bundle => 'com.apple.product-type.bundle',
|
111
|
+
:octest_bundle => 'com.apple.product-type.bundle',
|
107
112
|
:unit_test_bundle => 'com.apple.product-type.bundle.unit-test',
|
108
113
|
:app_extension => 'com.apple.product-type.app-extension',
|
109
114
|
:command_line_tool => 'com.apple.product-type.tool',
|
@@ -116,11 +121,13 @@ module Xcodeproj
|
|
116
121
|
# @return [Hash] The extensions or the various product UTIs.
|
117
122
|
#
|
118
123
|
PRODUCT_UTI_EXTENSIONS = {
|
119
|
-
:application
|
120
|
-
:framework
|
121
|
-
:dynamic_library
|
122
|
-
:static_library
|
123
|
-
:bundle
|
124
|
+
:application => 'app',
|
125
|
+
:framework => 'framework',
|
126
|
+
:dynamic_library => 'dylib',
|
127
|
+
:static_library => 'a',
|
128
|
+
:bundle => 'bundle',
|
129
|
+
:octest_bundle => 'octest',
|
130
|
+
:unit_test_bundle => 'xctest',
|
124
131
|
}.freeze
|
125
132
|
|
126
133
|
# @return [Hash] The common build settings grouped by platform, and build
|
@@ -406,9 +406,9 @@ module Xcodeproj
|
|
406
406
|
end
|
407
407
|
end
|
408
408
|
|
409
|
-
result = File.basename(x.display_name, '.*') <=> File.basename(y.display_name, '.*')
|
409
|
+
result = File.basename(x.display_name.downcase, '.*') <=> File.basename(y.display_name.downcase, '.*')
|
410
410
|
if result.zero?
|
411
|
-
File.extname(x.display_name) <=> File.extname(y.display_name)
|
411
|
+
File.extname(x.display_name.downcase) <=> File.extname(y.display_name.downcase)
|
412
412
|
else
|
413
413
|
result
|
414
414
|
end
|
data/lib/xcodeproj/scheme.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
require 'rexml/document'
|
2
2
|
|
3
|
+
require 'xcodeproj/scheme/build_action'
|
4
|
+
require 'xcodeproj/scheme/test_action'
|
5
|
+
require 'xcodeproj/scheme/launch_action'
|
6
|
+
require 'xcodeproj/scheme/profile_action'
|
7
|
+
require 'xcodeproj/scheme/analyze_action'
|
8
|
+
require 'xcodeproj/scheme/archive_action'
|
9
|
+
|
10
|
+
require 'xcodeproj/scheme/buildable_product_runnable'
|
11
|
+
require 'xcodeproj/scheme/buildable_reference'
|
12
|
+
require 'xcodeproj/scheme/macro_expansion'
|
13
|
+
|
3
14
|
module Xcodeproj
|
4
15
|
# This class represents a Scheme document represented by a ".xcscheme" file
|
5
16
|
# usually stored in a xcuserdata or xcshareddata (for a shared scheme)
|
@@ -11,61 +22,155 @@ module Xcodeproj
|
|
11
22
|
#
|
12
23
|
attr_reader :doc
|
13
24
|
|
14
|
-
# Create a
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
archive_action = @scheme.add_element 'ArchiveAction'
|
63
|
-
archive_action.attributes['buildConfiguration'] = 'Release'
|
64
|
-
archive_action.attributes['revealArchiveInOrganizer'] = 'YES'
|
25
|
+
# Create a XCScheme either from scratch or using an existing file
|
26
|
+
#
|
27
|
+
# @param [String] file_path
|
28
|
+
# The path of the existing .xcscheme file. If nil will create an empty scheme
|
29
|
+
#
|
30
|
+
def initialize(file_path = nil)
|
31
|
+
if file_path
|
32
|
+
@doc = REXML::Document.new(File.new(file_path))
|
33
|
+
@doc.context[:attribute_quote] = :quote
|
34
|
+
|
35
|
+
@scheme = @doc.elements['Scheme']
|
36
|
+
else
|
37
|
+
@doc = REXML::Document.new
|
38
|
+
@doc.context[:attribute_quote] = :quote
|
39
|
+
@doc << REXML::XMLDecl.new(REXML::XMLDecl::DEFAULT_VERSION, 'UTF-8')
|
40
|
+
|
41
|
+
@scheme = @doc.add_element 'Scheme'
|
42
|
+
@scheme.attributes['LastUpgradeVersion'] = Constants::LAST_UPGRADE_CHECK
|
43
|
+
@scheme.attributes['version'] = Xcodeproj::Constants::XCSCHEME_FORMAT_VERSION
|
44
|
+
|
45
|
+
self.build_action = BuildAction.new
|
46
|
+
self.test_action = TestAction.new
|
47
|
+
self.launch_action = LaunchAction.new
|
48
|
+
self.profile_action = ProfileAction.new
|
49
|
+
self.analyze_action = AnalyzeAction.new
|
50
|
+
self.archive_action = ArchiveAction.new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Convenience method to quickly add app and test targets to a new scheme.
|
55
|
+
#
|
56
|
+
# It will add the runnable_target to the Build, Launch and Profile actions
|
57
|
+
# and the test_target to the Build and Test actions
|
58
|
+
#
|
59
|
+
# @param [Xcodeproj::Project::Object::PBXAbstractTarget] runnable_target
|
60
|
+
# The target to use for the 'Run', 'Profile' and 'Analyze' actions
|
61
|
+
#
|
62
|
+
# @param [Xcodeproj::Project::Object::PBXAbstractTarget] test_target
|
63
|
+
# The target to use for the 'Test' action
|
64
|
+
#
|
65
|
+
def configure_with_targets(runnable_target, test_target)
|
66
|
+
build_action.add_entry BuildAction::Entry.new(runnable_target) if runnable_target
|
67
|
+
build_action.add_entry BuildAction::Entry.new(test_target) if test_target
|
68
|
+
|
69
|
+
test_action.add_testable TestAction::TestableReference.new(test_target) if test_target
|
70
|
+
launch_action.buildable_product_runnable = BuildableProductRunnable.new(runnable_target, 0) if runnable_target
|
71
|
+
profile_action.buildable_product_runnable = BuildableProductRunnable.new(runnable_target) if runnable_target
|
65
72
|
end
|
66
73
|
|
67
74
|
public
|
68
75
|
|
76
|
+
# @!group Access Action nodes
|
77
|
+
|
78
|
+
# @return [XCScheme::BuildAction]
|
79
|
+
# The Build Action associated with this scheme
|
80
|
+
#
|
81
|
+
def build_action
|
82
|
+
@build_action ||= BuildAction.new(@scheme.elements['BuildAction'])
|
83
|
+
end
|
84
|
+
|
85
|
+
# @param [XCScheme::BuildAction] action
|
86
|
+
# The Build Action to associate to this scheme
|
87
|
+
#
|
88
|
+
def build_action=(action)
|
89
|
+
@scheme.delete_element('BuildAction')
|
90
|
+
@scheme.add_element(action.xml_element)
|
91
|
+
@build_action = action
|
92
|
+
end
|
93
|
+
|
94
|
+
# @return [XCScheme::TestAction]
|
95
|
+
# The Test Action associated with this scheme
|
96
|
+
#
|
97
|
+
def test_action
|
98
|
+
@test_action ||= TestAction.new(@scheme.elements['TestAction'])
|
99
|
+
end
|
100
|
+
|
101
|
+
# @param [XCScheme::TestAction] action
|
102
|
+
# The Test Action to associate to this scheme
|
103
|
+
#
|
104
|
+
def test_action=(action)
|
105
|
+
@scheme.delete_element('TestAction')
|
106
|
+
@scheme.add_element(action.xml_element)
|
107
|
+
@test_action = action
|
108
|
+
end
|
109
|
+
|
110
|
+
# @return [XCScheme::LaunchAction]
|
111
|
+
# The Launch Action associated with this scheme
|
112
|
+
#
|
113
|
+
def launch_action
|
114
|
+
@launch_action ||= LaunchAction.new(@scheme.elements['LaunchAction'])
|
115
|
+
end
|
116
|
+
|
117
|
+
# @param [XCScheme::LaunchAction] action
|
118
|
+
# The Launch Action to associate to this scheme
|
119
|
+
#
|
120
|
+
def launch_action=(action)
|
121
|
+
@scheme.delete_element('LaunchAction')
|
122
|
+
@scheme.add_element(action.xml_element)
|
123
|
+
@launch_action = action
|
124
|
+
end
|
125
|
+
|
126
|
+
# @return [XCScheme::ProfileAction]
|
127
|
+
# The Profile Action associated with this scheme
|
128
|
+
#
|
129
|
+
def profile_action
|
130
|
+
@profile_action ||= ProfileAction.new(@scheme.elements['ProfileAction'])
|
131
|
+
end
|
132
|
+
|
133
|
+
# @param [XCScheme::ProfileAction] action
|
134
|
+
# The Profile Action to associate to this scheme
|
135
|
+
#
|
136
|
+
def profile_action=(action)
|
137
|
+
@scheme.delete_element('ProfileAction')
|
138
|
+
@scheme.add_element(action.xml_element)
|
139
|
+
@profile_action = action
|
140
|
+
end
|
141
|
+
|
142
|
+
# @return [XCScheme::AnalyzeAction]
|
143
|
+
# The Analyze Action associated with this scheme
|
144
|
+
#
|
145
|
+
def analyze_action
|
146
|
+
@analyze_action ||= AnalyzeAction.new(@scheme.elements['AnalyzeAction'])
|
147
|
+
end
|
148
|
+
|
149
|
+
# @param [XCScheme::AnalyzeAction] action
|
150
|
+
# The Analyze Action to associate to this scheme
|
151
|
+
#
|
152
|
+
def analyze_action=(action)
|
153
|
+
@scheme.delete_element('AnalyzeAction')
|
154
|
+
@scheme.add_element(action.xml_element)
|
155
|
+
@analyze_action = action
|
156
|
+
end
|
157
|
+
|
158
|
+
# @return [XCScheme::ArchiveAction]
|
159
|
+
# The Archive Action associated with this scheme
|
160
|
+
#
|
161
|
+
def archive_action
|
162
|
+
@archive_action ||= ArchiveAction.new(@scheme.elements['ArchiveAction'])
|
163
|
+
end
|
164
|
+
|
165
|
+
# @param [XCScheme::ArchiveAction] action
|
166
|
+
# The Archive Action to associate to this scheme
|
167
|
+
#
|
168
|
+
def archive_action=(action)
|
169
|
+
@scheme.delete_element('ArchiveAction')
|
170
|
+
@scheme.add_element(action.xml_element)
|
171
|
+
@archive_action = action
|
172
|
+
end
|
173
|
+
|
69
174
|
# @!group Target methods
|
70
175
|
|
71
176
|
# Add a target to the list of targets to build in the build action.
|
@@ -77,23 +182,15 @@ module Xcodeproj
|
|
77
182
|
# Whether to build this target in the launch action. Often false for test targets.
|
78
183
|
#
|
79
184
|
def add_build_target(build_target, build_for_running = true)
|
80
|
-
|
81
|
-
@build_action_entries = @build_action.add_element 'BuildActionEntries'
|
82
|
-
end
|
185
|
+
entry = BuildAction::Entry.new(build_target)
|
83
186
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
buildable_reference = build_action_entry.add_element 'BuildableReference'
|
92
|
-
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
93
|
-
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
94
|
-
buildable_reference.attributes['BuildableName'] = construct_buildable_name(build_target)
|
95
|
-
buildable_reference.attributes['BlueprintName'] = build_target.name
|
96
|
-
buildable_reference.attributes['ReferencedContainer'] = construct_referenced_container_uri(build_target)
|
187
|
+
entry.build_for_testing = true
|
188
|
+
entry.build_for_running = build_for_running
|
189
|
+
entry.build_for_profiling = true
|
190
|
+
entry.build_for_archiving = true
|
191
|
+
entry.build_for_analyzing = true
|
192
|
+
|
193
|
+
build_action.add_entry(entry)
|
97
194
|
end
|
98
195
|
|
99
196
|
# Add a target to the list of targets to build in the build action.
|
@@ -102,15 +199,8 @@ module Xcodeproj
|
|
102
199
|
# A target used by scheme in the test step.
|
103
200
|
#
|
104
201
|
def add_test_target(test_target)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
buildable_reference = testable_reference.add_element 'BuildableReference'
|
109
|
-
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
110
|
-
buildable_reference.attributes['BlueprintIdentifier'] = test_target.uuid
|
111
|
-
buildable_reference.attributes['BuildableName'] = "#{test_target.name}.octest"
|
112
|
-
buildable_reference.attributes['BlueprintName'] = test_target.name
|
113
|
-
buildable_reference.attributes['ReferencedContainer'] = construct_referenced_container_uri(test_target)
|
202
|
+
testable = TestAction::TestableReference.new(test_target)
|
203
|
+
test_action.add_testable(testable)
|
114
204
|
end
|
115
205
|
|
116
206
|
# Sets a runnable target to be the target of the launch action of the scheme.
|
@@ -119,33 +209,14 @@ module Xcodeproj
|
|
119
209
|
# A target used by scheme in the launch step.
|
120
210
|
#
|
121
211
|
def set_launch_target(build_target)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
launch_buildable_reference.attributes['ReferencedContainer'] = construct_referenced_container_uri(build_target)
|
131
|
-
|
132
|
-
profile_product_runnable = @profile_action.add_element 'BuildableProductRunnable'
|
133
|
-
|
134
|
-
profile_buildable_reference = profile_product_runnable.add_element 'BuildableReference'
|
135
|
-
profile_buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
136
|
-
profile_buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
137
|
-
profile_buildable_reference.attributes['BuildableName'] = "#{build_target.name}.app"
|
138
|
-
profile_buildable_reference.attributes['BlueprintName'] = build_target.name
|
139
|
-
profile_buildable_reference.attributes['ReferencedContainer'] = construct_referenced_container_uri(build_target)
|
140
|
-
|
141
|
-
macro_expansion = @test_action.add_element 'MacroExpansion'
|
142
|
-
|
143
|
-
buildable_reference = macro_expansion.add_element 'BuildableReference'
|
144
|
-
buildable_reference.attributes['BuildableIdentifier'] = 'primary'
|
145
|
-
buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
|
146
|
-
buildable_reference.attributes['BuildableName'] = File.basename(build_target.product_reference.path)
|
147
|
-
buildable_reference.attributes['BlueprintName'] = build_target.name
|
148
|
-
buildable_reference.attributes['ReferencedContainer'] = construct_referenced_container_uri(build_target)
|
212
|
+
launch_runnable = BuildableProductRunnable.new(build_target, 0)
|
213
|
+
launch_action.buildable_product_runnable = launch_runnable
|
214
|
+
|
215
|
+
profile_runnable = BuildableProductRunnable.new(build_target)
|
216
|
+
profile_action.buildable_product_runnable = profile_runnable
|
217
|
+
|
218
|
+
macro_exp = MacroExpansion.new(build_target)
|
219
|
+
test_action.add_macro_expansion(macro_exp)
|
149
220
|
end
|
150
221
|
|
151
222
|
# @!group Class methods
|
@@ -272,39 +343,5 @@ module Xcodeproj
|
|
272
343
|
end
|
273
344
|
|
274
345
|
#-------------------------------------------------------------------------#
|
275
|
-
|
276
|
-
private
|
277
|
-
|
278
|
-
# @!group Private helpers
|
279
|
-
|
280
|
-
# @param [Xcodeproj::Project::Object::AbstractTarget] target
|
281
|
-
#
|
282
|
-
# @return [String] The buildable name of the scheme.
|
283
|
-
#
|
284
|
-
def construct_buildable_name(build_target)
|
285
|
-
case build_target.isa
|
286
|
-
when 'PBXNativeTarget'
|
287
|
-
File.basename(build_target.product_reference.path)
|
288
|
-
when 'PBXAggregateTarget'
|
289
|
-
build_target.name
|
290
|
-
else
|
291
|
-
raise ArgumentError, "Unsupported build target type #{build_target.isa}"
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
# @param [Xcodeproj::Project::Object::AbstractTarget] target
|
296
|
-
#
|
297
|
-
# @return [String] A string in the format "container:[path to the project
|
298
|
-
# file relative to the project_dir_path, always ending with
|
299
|
-
# the actual project directory name]"
|
300
|
-
#
|
301
|
-
def construct_referenced_container_uri(target)
|
302
|
-
project = target.project
|
303
|
-
relative_path = project.path.relative_path_from(project.path + project.root_object.project_dir_path).to_s
|
304
|
-
relative_path = project.path.basename if relative_path == '.'
|
305
|
-
"container:#{relative_path}"
|
306
|
-
end
|
307
|
-
|
308
|
-
#-------------------------------------------------------------------------#
|
309
346
|
end
|
310
347
|
end
|