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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3ffe9ba21a5d156f491061b65e4a600ada8c653
4
- data.tar.gz: b4327d4cdbbd7036dcd891c478f850ac19fdd8ea
3
+ metadata.gz: 06e0ee7bf2c3ae317b24d55195a21d22c9018a67
4
+ data.tar.gz: e07317fcef70ba2aa4969bbea76bda7c3a0f52ff
5
5
  SHA512:
6
- metadata.gz: 86aa2035f0857282fa84bc0bc13827d4523ce0724f25b4f31883c693e8724478555d85404d437de96ae54efae2720c20724b3c5e8685a7eaf60fafd8f422c1c7
7
- data.tar.gz: 0f5707dee287885c37cb5fbafe17ae3832f4556a645e8b354486ab1f9b48976047511a323c77eff50aac3154cec536ed167510167397e0725a27972470351820
6
+ metadata.gz: f3ed731a9be7088415abe1e113b7d7ec85113a735217063b41b38c7da5e8111701a86470843ae17df1f2529304706e7853b49b2fb73d3d5008aeb3586b67baf0
7
+ data.tar.gz: 88be395b0399c6bc5e879d9cb94cd9785b5efa8ee5545b13d83b3a435cd932f2367b35e7db6beb10fa4e80816895c781b1287b6d857301d99c4edf323ccc08a8
@@ -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] }]
@@ -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 => 'app',
120
- :framework => 'framework',
121
- :dynamic_library => 'dylib',
122
- :static_library => 'a',
123
- :bundle => '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
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '0.26.3' unless defined? Xcodeproj::VERSION
4
+ VERSION = '0.27.0' unless defined? Xcodeproj::VERSION
5
5
  end
@@ -145,7 +145,7 @@ module Xcodeproj
145
145
  to_many_attributes.each do |attrb|
146
146
  list = attrb.get_value(self)
147
147
  list.sort! do |x, y|
148
- x.display_name <=> y.display_name
148
+ x.display_name.downcase <=> y.display_name.downcase
149
149
  end
150
150
  end
151
151
  end
@@ -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
@@ -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 new XCScheme instance
15
- #
16
- def initialize
17
- @doc = REXML::Document.new
18
- @doc << REXML::XMLDecl.new(REXML::XMLDecl::DEFAULT_VERSION, 'UTF-8')
19
- @doc.context[:attribute_quote] = :quote
20
-
21
- @scheme = @doc.add_element 'Scheme'
22
- @scheme.attributes['LastUpgradeVersion'] = Constants::LAST_UPGRADE_CHECK
23
- @scheme.attributes['version'] = '1.3'
24
-
25
- @build_action = @scheme.add_element 'BuildAction'
26
- @build_action.attributes['parallelizeBuildables'] = 'YES'
27
- @build_action.attributes['buildImplicitDependencies'] = 'YES'
28
- @build_action_entries = nil
29
-
30
- @test_action = @scheme.add_element 'TestAction'
31
- @test_action.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
32
- @test_action.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
33
- @test_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
34
- @test_action.attributes['buildConfiguration'] = 'Debug'
35
-
36
- @test_action_additional_options = @test_action.add_element 'AdditionalOptions'
37
-
38
- @testables = @test_action.add_element 'Testables'
39
-
40
- @launch_action = @scheme.add_element 'LaunchAction'
41
- @launch_action.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
42
- @launch_action.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
43
- @launch_action.attributes['launchStyle'] = '0'
44
- @launch_action.attributes['useCustomWorkingDirectory'] = 'NO'
45
- @launch_action.attributes['buildConfiguration'] = 'Debug'
46
- @launch_action.attributes['ignoresPersistentStateOnLaunch'] = 'NO'
47
- @launch_action.attributes['debugDocumentVersioning'] = 'YES'
48
- @launch_action.attributes['debugServiceExtension'] = 'internal'
49
- @launch_action.attributes['allowLocationSimulation'] = 'YES'
50
- @launch_action.add_element('AdditionalOptions')
51
-
52
- @profile_action = @scheme.add_element 'ProfileAction'
53
- @profile_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
54
- @profile_action.attributes['savedToolIdentifier'] = ''
55
- @profile_action.attributes['useCustomWorkingDirectory'] = 'NO'
56
- @profile_action.attributes['buildConfiguration'] = 'Release'
57
- @profile_action.attributes['debugDocumentVersioning'] = 'YES'
58
-
59
- analyze_action = @scheme.add_element 'AnalyzeAction'
60
- analyze_action.attributes['buildConfiguration'] = 'Debug'
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
- unless @build_action_entries
81
- @build_action_entries = @build_action.add_element 'BuildActionEntries'
82
- end
185
+ entry = BuildAction::Entry.new(build_target)
83
186
 
84
- build_action_entry = @build_action_entries.add_element 'BuildActionEntry'
85
- build_action_entry.attributes['buildForTesting'] = 'YES'
86
- build_action_entry.attributes['buildForRunning'] = build_for_running ? 'YES' : 'NO'
87
- build_action_entry.attributes['buildForProfiling'] = 'YES'
88
- build_action_entry.attributes['buildForArchiving'] = 'YES'
89
- build_action_entry.attributes['buildForAnalyzing'] = 'YES'
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
- testable_reference = @testables.add_element 'TestableReference'
106
- testable_reference.attributes['skipped'] = 'NO'
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
- launch_product_runnable = @launch_action.add_element 'BuildableProductRunnable'
123
- launch_product_runnable.attributes['runnableDebuggingMode'] = '0'
124
-
125
- launch_buildable_reference = launch_product_runnable.add_element 'BuildableReference'
126
- launch_buildable_reference.attributes['BuildableIdentifier'] = 'primary'
127
- launch_buildable_reference.attributes['BlueprintIdentifier'] = build_target.uuid
128
- launch_buildable_reference.attributes['BuildableName'] = "#{build_target.name}.app"
129
- launch_buildable_reference.attributes['BlueprintName'] = build_target.name
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