xcodeproj 0.18.0 → 0.19.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/bin/xcodeproj +5 -5
  3. data/lib/xcodeproj.rb +0 -2
  4. data/lib/xcodeproj/command.rb +26 -17
  5. data/lib/xcodeproj/command/project_diff.rb +8 -11
  6. data/lib/xcodeproj/command/show.rb +8 -10
  7. data/lib/xcodeproj/command/sort.rb +4 -7
  8. data/lib/xcodeproj/command/target_diff.rb +4 -5
  9. data/lib/xcodeproj/config.rb +64 -57
  10. data/lib/xcodeproj/config/other_linker_flags_parser.rb +62 -0
  11. data/lib/xcodeproj/constants.rb +31 -30
  12. data/lib/xcodeproj/differ.rb +5 -9
  13. data/lib/xcodeproj/gem_version.rb +1 -2
  14. data/lib/xcodeproj/helper.rb +5 -4
  15. data/lib/xcodeproj/plist_helper.rb +46 -11
  16. data/lib/xcodeproj/project.rb +16 -20
  17. data/lib/xcodeproj/project/case_converter.rb +59 -0
  18. data/lib/xcodeproj/project/object.rb +40 -30
  19. data/lib/xcodeproj/project/object/build_configuration.rb +1 -5
  20. data/lib/xcodeproj/project/object/build_file.rb +1 -4
  21. data/lib/xcodeproj/project/object/build_phase.rb +2 -13
  22. data/lib/xcodeproj/project/object/build_rule.rb +0 -3
  23. data/lib/xcodeproj/project/object/configuration_list.rb +0 -4
  24. data/lib/xcodeproj/project/object/container_item_proxy.rb +2 -4
  25. data/lib/xcodeproj/project/object/file_reference.rb +3 -6
  26. data/lib/xcodeproj/project/object/group.rb +6 -14
  27. data/lib/xcodeproj/project/object/helpers/file_references_factory.rb +64 -13
  28. data/lib/xcodeproj/project/object/helpers/groupable_helper.rb +4 -6
  29. data/lib/xcodeproj/project/object/native_target.rb +18 -29
  30. data/lib/xcodeproj/project/object/reference_proxy.rb +0 -4
  31. data/lib/xcodeproj/project/object/root_object.rb +4 -8
  32. data/lib/xcodeproj/project/object/target_dependency.rb +1 -4
  33. data/lib/xcodeproj/project/object_attributes.rb +76 -33
  34. data/lib/xcodeproj/project/object_dictionary.rb +76 -63
  35. data/lib/xcodeproj/project/object_list.rb +5 -9
  36. data/lib/xcodeproj/project/project_helper.rb +2 -7
  37. data/lib/xcodeproj/project/xcproj_helper.rb +0 -2
  38. data/lib/xcodeproj/scheme.rb +12 -15
  39. data/lib/xcodeproj/user_interface.rb +0 -4
  40. data/lib/xcodeproj/workspace.rb +36 -23
  41. data/lib/xcodeproj/workspace/file_reference.rb +3 -3
  42. data/lib/xcodeproj/xcodebuild_helper.rb +0 -6
  43. metadata +20 -18
@@ -0,0 +1,59 @@
1
+ module Xcodeproj
2
+ class Project
3
+ module Object
4
+ # Converts between camel case names used in the xcodeproj plist files
5
+ # and the ruby symbols used to represent them.
6
+ #
7
+ module CaseConverter
8
+ # @return [String] The plist equivalent of the given Ruby name.
9
+ #
10
+ # @param [Symbol, String] name
11
+ # The name to convert
12
+ #
13
+ # @param [Symbol, Nil] type
14
+ # The type of conversion. Pass `nil` for normal camel case and
15
+ # `:lower` for camel case starting with a lower case letter.
16
+ #
17
+ # @example
18
+ # CaseConverter.convert_to_plist(:project_ref) #=> ProjectRef
19
+ #
20
+ def self.convert_to_plist(name, type = nil)
21
+ case name
22
+ when :remote_global_id_string
23
+ 'remoteGlobalIDString'
24
+ else
25
+ if type == :lower
26
+ cache = plist_cache[:lower] ||= {}
27
+ cache[name] ||= name.to_s.camelize(:lower)
28
+ else
29
+ cache = plist_cache[:normal] ||= {}
30
+ cache[name] ||= name.to_s.camelize
31
+ end
32
+ end
33
+ end
34
+
35
+ # @return [Symbol] The Ruby equivalent of the given plist name.
36
+ #
37
+ # @param [String] name
38
+ # The name to convert
39
+ #
40
+ # @example
41
+ # CaseConverter.convert_to_ruby('ProjectRef') #=> :project_ref
42
+ #
43
+ def self.convert_to_ruby(name)
44
+ name.to_s.underscore.to_sym
45
+ end
46
+
47
+ # @return [Hash] A cache for the conversion to the Plist format.
48
+ #
49
+ # @note A cache is used because this operation is performed for each
50
+ # attribute of the project when it is saved and caching it has
51
+ # an important performance benefit.
52
+ #
53
+ def self.plist_cache
54
+ @plist_cache ||= {}
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,6 +1,5 @@
1
1
  module Xcodeproj
2
2
  class Project
3
-
4
3
  # This is the namespace in which all the classes that wrap the objects in
5
4
  # a Xcode project reside.
6
5
  #
@@ -16,7 +15,6 @@ module Xcodeproj
16
15
  # end
17
16
  #
18
17
  module Object
19
-
20
18
  # @abstract
21
19
  #
22
20
  # This is the base class of all object types that can exist in a Xcode
@@ -34,7 +32,6 @@ module Xcodeproj
34
32
  # clients.
35
33
  #
36
34
  class AbstractObject
37
-
38
35
  # @!group AbstractObject
39
36
 
40
37
  # @return [String] the ISA of the class.
@@ -65,7 +62,9 @@ module Xcodeproj
65
62
  @project, @uuid = project, uuid
66
63
  @isa = self.class.isa
67
64
  @referrers = []
68
- raise "[Xcodeproj] Attempt to initialize an abstract class." unless @isa.match(/^(PBX|XC)/)
65
+ unless @isa.match(/^(PBX|XC)/)
66
+ raise '[Xcodeproj] Attempt to initialize an abstract class.'
67
+ end
69
68
  end
70
69
 
71
70
  # Initializes the object with the default values of simple attributes.
@@ -100,7 +99,10 @@ module Xcodeproj
100
99
  #
101
100
  def remove_from_project
102
101
  project.objects_by_uuid.delete(uuid)
103
- referrers.each { |referrer| referrer.remove_reference(self) }
102
+
103
+ referrers.dup.each do |referrer|
104
+ referrer.remove_reference(self)
105
+ end
104
106
 
105
107
  to_one_attributes.each do |attrb|
106
108
  object = attrb.get_value(self)
@@ -112,7 +114,10 @@ module Xcodeproj
112
114
  list.clear
113
115
  end
114
116
 
115
- raise "[Xcodeproj] BUG: #{self} should have no referrers instead the following objects are still referencing it #{referrers}" unless referrers.count == 0
117
+ unless referrers.count == 0
118
+ raise "[Xcodeproj] BUG: #{self} should have no referrers instead" \
119
+ "the following objects are still referencing it #{referrers}"
120
+ end
116
121
  end
117
122
 
118
123
  # Returns the value of the name attribute or returns a generic name for
@@ -131,12 +136,12 @@ module Xcodeproj
131
136
  isa.gsub(/^(PBX|XC)/, '')
132
137
  end
133
138
  end
134
- alias :to_s :display_name
139
+ alias_method :to_s, :display_name
135
140
 
136
141
  # Sorts the to many attributes of the object according to the display
137
142
  # name.
138
143
  #
139
- def sort(options = nil)
144
+ def sort(_options = nil)
140
145
  to_many_attributes.each do |attrb|
141
146
  list = attrb.get_value(self)
142
147
  list.sort! do |x, y|
@@ -255,7 +260,10 @@ module Xcodeproj
255
260
  def configure_with_plist(objects_by_uuid_plist)
256
261
  object_plist = objects_by_uuid_plist[uuid].dup
257
262
 
258
- raise "[Xcodeproj] Attempt to initialize `#{isa}` from plist with different isa `#{object_plist}`" unless object_plist['isa'] == isa
263
+ unless object_plist['isa'] == isa
264
+ raise "[Xcodeproj] Attempt to initialize `#{isa}` from plist with " \
265
+ "different isa `#{object_plist}`"
266
+ end
259
267
  object_plist.delete('isa')
260
268
 
261
269
  simple_attributes.each do |attrb|
@@ -297,9 +305,10 @@ module Xcodeproj
297
305
  end
298
306
 
299
307
  unless object_plist.empty?
300
- raise "[!] Xcodeproj doesn't know about the following attributes " \
301
- "#{object_plist.inspect} for the '#{isa}' isa.\n" \
302
- "Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
308
+ raise "[!] Xcodeproj doesn't know about the following " \
309
+ "attributes #{object_plist.inspect} for the '#{isa}' isa." \
310
+ "\nIf this attribute was generated by Xcode please file " \
311
+ 'an issue: https://github.com/CocoaPods/Xcodeproj/issues/new'
303
312
  end
304
313
  end
305
314
 
@@ -327,16 +336,17 @@ module Xcodeproj
327
336
  def object_with_uuid(uuid, objects_by_uuid_plist, attribute)
328
337
  unless object = project.objects_by_uuid[uuid] || project.new_from_plist(uuid, objects_by_uuid_plist)
329
338
  UI.warn "`#{inspect}` attempted to initialize an object with " \
330
- "an unknown UUID. `#{uuid}` for attribute: `#{attribute.name}`."\
331
- " This can be the result of a merge and the unknown UUID is " \
332
- "being discarded."
339
+ "an unknown UUID. `#{uuid}` for attribute: " \
340
+ "`#{attribute.name}`. This can be the result of a merge and " \
341
+ 'the unknown UUID is being discarded.'
333
342
  end
334
343
  object
335
344
  rescue NameError
336
345
  attributes = objects_by_uuid_plist[uuid]
337
346
  raise "`#{isa}` attempted to initialize an object with unknown ISA "\
338
- "`#{attributes['isa']}` from attributes: `#{attributes}`\n" \
339
- "Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
347
+ "`#{attributes['isa']}` from attributes: `#{attributes}`\n" \
348
+ 'If this ISA was generated by Xcode please file an issue: ' \
349
+ 'https://github.com/CocoaPods/Xcodeproj/issues/new'
340
350
  end
341
351
 
342
352
  # Returns a cascade representation of the object with UUIDs.
@@ -364,13 +374,13 @@ module Xcodeproj
364
374
  end
365
375
 
366
376
  to_many_attributes.each do |attrb|
367
- list = attrb.get_value(self)
377
+ list = attrb.get_value(self)
368
378
  plist[attrb.plist_name] = list.uuids
369
379
  end
370
380
 
371
381
  references_by_keys_attributes.each do |attrb|
372
382
  list = attrb.get_value(self)
373
- plist[attrb.plist_name] = list.map { |dictionary| dictionary.to_hash }
383
+ plist[attrb.plist_name] = list.map(&:to_hash)
374
384
  end
375
385
 
376
386
  plist
@@ -406,12 +416,12 @@ module Xcodeproj
406
416
 
407
417
  to_many_attributes.each do |attrb|
408
418
  list = attrb.get_value(self)
409
- hash[attrb.plist_name] = list.map { |obj| obj.to_tree_hash }
419
+ hash[attrb.plist_name] = list.map(&:to_tree_hash)
410
420
  end
411
421
 
412
422
  references_by_keys_attributes.each do |attrb|
413
423
  list = attrb.get_value(self)
414
- hash[attrb.plist_name] = list.map { |dictionary| dictionary.to_tree_hash }
424
+ hash[attrb.plist_name] = list.map(&:to_tree_hash)
415
425
  end
416
426
 
417
427
  hash
@@ -423,7 +433,7 @@ module Xcodeproj
423
433
  def pretty_print
424
434
  if to_many_attributes.count == 1
425
435
  children = to_many_attributes.first.get_value(self)
426
- {display_name => children.map(&:pretty_print)}
436
+ { display_name => children.map(&:pretty_print) }
427
437
  else
428
438
  display_name
429
439
  end
@@ -436,27 +446,28 @@ module Xcodeproj
436
446
  # @!group Object methods
437
447
 
438
448
  def ==(other)
439
- other.is_a?(AbstractObject) && self.to_hash == other.to_hash
449
+ other.is_a?(AbstractObject) && to_hash == other.to_hash
440
450
  end
441
451
 
442
452
  def <=>(other)
443
- self.uuid <=> other.uuid
453
+ uuid <=> other.uuid
444
454
  end
445
455
 
446
456
  def inspect
447
457
  optional = ''
448
- optional << " name=`#{self.name}`" if respond_to?(:name) && self.name
449
- optional << " path=`#{self.path}`" if respond_to?(:path) && self.path
450
- "<#{self.isa}#{optional} UUID=`#{uuid}`>"
458
+ optional << " name=`#{name}`" if respond_to?(:name) && name
459
+ optional << " path=`#{path}`" if respond_to?(:path) && path
460
+ "<#{isa}#{optional} UUID=`#{uuid}`>"
451
461
  end
452
462
  end
453
463
  end
454
464
  end
455
465
  end
456
466
 
457
- require 'xcodeproj/project/object_list'
458
- require 'xcodeproj/project/object_dictionary'
467
+ require 'xcodeproj/project/case_converter'
459
468
  require 'xcodeproj/project/object_attributes'
469
+ require 'xcodeproj/project/object_dictionary'
470
+ require 'xcodeproj/project/object_list'
460
471
 
461
472
  # Required because some classes have cyclical references to each other.
462
473
  #
@@ -488,4 +499,3 @@ require 'xcodeproj/project/object/native_target'
488
499
  require 'xcodeproj/project/object/root_object'
489
500
  require 'xcodeproj/project/object/target_dependency'
490
501
  require 'xcodeproj/project/object/reference_proxy'
491
-
@@ -1,13 +1,11 @@
1
1
  module Xcodeproj
2
2
  class Project
3
3
  module Object
4
-
5
4
  # Encapsulates the information a specific build configuration referenced
6
5
  # by a {XCConfigurationList} which in turn might be referenced by a
7
6
  # {PBXProject} or a {PBXNativeTarget}.
8
7
  #
9
8
  class XCBuildConfiguration < AbstractObject
10
-
11
9
  # @!group Attributes
12
10
 
13
11
  # @return [String] the name of the Target.
@@ -23,7 +21,6 @@ module Xcodeproj
23
21
  #
24
22
  has_one :base_configuration_reference, PBXFileReference
25
23
 
26
-
27
24
  public
28
25
 
29
26
  # @!group AbstractObject Hooks
@@ -46,7 +43,7 @@ module Xcodeproj
46
43
  #
47
44
  # @return [void]
48
45
  #
49
- def sort(options = nil)
46
+ def sort(_options = nil)
50
47
  sorted = {}
51
48
  build_settings.keys.sort.each do |key|
52
49
  sorted[key] = build_settings[key]
@@ -55,7 +52,6 @@ module Xcodeproj
55
52
  end
56
53
 
57
54
  #---------------------------------------------------------------------#
58
-
59
55
  end
60
56
  end
61
57
  end
@@ -1,12 +1,10 @@
1
1
  module Xcodeproj
2
2
  class Project
3
3
  module Object
4
-
5
4
  # Contains the information about the build settings of a file used by an
6
5
  # {AbstractBuildPhase}.
7
6
  #
8
7
  class PBXBuildFile < AbstractObject
9
-
10
8
  # @!group Attributes
11
9
 
12
10
  # @return [Hash] the list of build settings for this file.
@@ -30,7 +28,7 @@ module Xcodeproj
30
28
  PBXGroup,
31
29
  PBXVariantGroup,
32
30
  XCVersionGroup,
33
- PBXReferenceProxy
31
+ PBXReferenceProxy,
34
32
  ]
35
33
 
36
34
  #---------------------------------------------------------------------#
@@ -62,7 +60,6 @@ module Xcodeproj
62
60
  end
63
61
 
64
62
  #---------------------------------------------------------------------#
65
-
66
63
  end
67
64
  end
68
65
  end
@@ -1,13 +1,11 @@
1
1
  module Xcodeproj
2
2
  class Project
3
3
  module Object
4
-
5
4
  # @abstract
6
5
  #
7
6
  # This class is abstract and it doesn't appear in the project document.
8
7
  #
9
8
  class AbstractBuildPhase < AbstractObject
10
-
11
9
  # @!group Attributes
12
10
 
13
11
  # @return [ObjectList<PBXBuildFile>] the files processed by this build
@@ -48,7 +46,7 @@ module Xcodeproj
48
46
  # referenced by this build phase.
49
47
  #
50
48
  def files_references
51
- files.map { |bf| bf.file_ref }
49
+ files.map(&:file_ref)
52
50
  end
53
51
 
54
52
  # @return [Array<String>] The display name of the build files.
@@ -128,8 +126,7 @@ module Xcodeproj
128
126
  remove_build_file(bf)
129
127
  end
130
128
  end
131
- alias :clear_build_files :clear
132
-
129
+ alias_method :clear_build_files, :clear
133
130
  end
134
131
 
135
132
  #-----------------------------------------------------------------------#
@@ -140,7 +137,6 @@ module Xcodeproj
140
137
  # @note This phase can appear only once in a target.
141
138
  #
142
139
  class PBXHeadersBuildPhase < AbstractBuildPhase
143
-
144
140
  end
145
141
 
146
142
  #-----------------------------------------------------------------------#
@@ -151,7 +147,6 @@ module Xcodeproj
151
147
  # @note This phase can appear only once in a target.
152
148
  #
153
149
  class PBXSourcesBuildPhase < AbstractBuildPhase
154
-
155
150
  end
156
151
 
157
152
  #-----------------------------------------------------------------------#
@@ -162,7 +157,6 @@ module Xcodeproj
162
157
  # @note This phase can appear only once in a target.
163
158
  #
164
159
  class PBXFrameworksBuildPhase < AbstractBuildPhase
165
-
166
160
  end
167
161
 
168
162
  #-----------------------------------------------------------------------#
@@ -174,7 +168,6 @@ module Xcodeproj
174
168
  # @note This phase can appear only once in a target.
175
169
  #
176
170
  class PBXResourcesBuildPhase < AbstractBuildPhase
177
-
178
171
  end
179
172
 
180
173
  #-----------------------------------------------------------------------#
@@ -185,7 +178,6 @@ module Xcodeproj
185
178
  # @note This phase can appear multiple times in a target.
186
179
  #
187
180
  class PBXCopyFilesBuildPhase < AbstractBuildPhase
188
-
189
181
  # @!group Attributes
190
182
 
191
183
  # @return [String] the name of the build phase.
@@ -203,7 +195,6 @@ module Xcodeproj
203
195
  # copied to.
204
196
  #
205
197
  attribute :dst_subfolder_spec, String, Constants::COPY_FILES_BUILD_PHASE_DESTINATIONS[:resources]
206
-
207
198
  end
208
199
 
209
200
  #-----------------------------------------------------------------------#
@@ -213,7 +204,6 @@ module Xcodeproj
213
204
  # @note This phase can appear multiple times in a target.
214
205
  #
215
206
  class PBXShellScriptBuildPhase < AbstractBuildPhase
216
-
217
207
  # @!group Attributes
218
208
 
219
209
  # @return [String] the name of the build phase.
@@ -265,7 +255,6 @@ module Xcodeproj
265
255
  end
266
256
 
267
257
  #-----------------------------------------------------------------------#
268
-
269
258
  end
270
259
  end
271
260
  end
@@ -1,11 +1,9 @@
1
1
  module Xcodeproj
2
2
  class Project
3
3
  module Object
4
-
5
4
  # This class represents a custom build rule of a Target.
6
5
  #
7
6
  class PBXBuildRule < AbstractObject
8
-
9
7
  # @!group Attributes
10
8
 
11
9
  # @return [String] the name of the rule.
@@ -54,7 +52,6 @@ module Xcodeproj
54
52
  # `com.apple.compilers.proxy.script`
55
53
  #
56
54
  attribute :script, String
57
-
58
55
  end
59
56
  end
60
57
  end
@@ -1,12 +1,10 @@
1
1
  module Xcodeproj
2
2
  class Project
3
3
  module Object
4
-
5
4
  # The primary purpose of this class is to maintain a collection of
6
5
  # related build configurations of a {PBXProject} or a {PBXNativeTarget}.
7
6
  #
8
7
  class XCConfigurationList < AbstractObject
9
-
10
8
  # @!group Attributes
11
9
 
12
10
  # @return [String] whether the default configuration is visible.
@@ -27,7 +25,6 @@ module Xcodeproj
27
25
  #
28
26
  has_many :build_configurations, XCBuildConfiguration
29
27
 
30
-
31
28
  public
32
29
 
33
30
  # @!group Helpers
@@ -94,7 +91,6 @@ module Xcodeproj
94
91
  end
95
92
 
96
93
  #---------------------------------------------------------------------#
97
-
98
94
  end
99
95
  end
100
96
  end