xcodeproj 1.21.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bab98461310ae1a7572bae0b8dd9025cdf12ee53a64c7d457e8d4982d71982d
4
- data.tar.gz: 59d1ddc2130ee7f88eb646a1c98dbf14e45da612448a12425df004d416f93961
3
+ metadata.gz: e0788725232bb312e7454dbec2640d078bd514c469deeeff4e57544e837187ac
4
+ data.tar.gz: fc1af51df95f4fdcaee3040adafdb0afaf5de03e036a32d2769c7af9a2d36fd5
5
5
  SHA512:
6
- metadata.gz: 4e2431ba9cbf960b7e1ef53ff3dae65565b51fbba1cbb0c6a096d29251ca49c751403575c46fdae6252e176b8ada16ac5aa659d6b015f142eb338e21718a7a38
7
- data.tar.gz: dfe1895012ba35e32dd44b15b4b2cb5e8ab2957eb7919f39a514c7675b8a261a4f4688006ace24e6eae0dcfc07be70392cf047f0cb66bd8f1036bc3fe817f366
6
+ metadata.gz: 39a057723656bb7016aa845c427a90c1c6e264f34c3c8eee67b424a7952975371ad56e44569b7e0681154cbd2a4ed2bb82589dc1087a95969d64cfa2c5a5654a
7
+ data.tar.gz: c9c72a16fe6597d7b6408b49ec6d98083c7e828e444b9e3a17c5155da69e1d3f6869ccfdbaa074eeb13537e81c5e214fb8dc1a975a8633a6c2c718333748fd2b
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Xcodeproj
2
2
 
3
- [![Build Status](https://img.shields.io/travis/CocoaPods/Xcodeproj/master.svg?style=flat)](https://travis-ci.org/CocoaPods/Xcodeproj)
4
- [![Coverage](https://img.shields.io/codeclimate/coverage/github/CocoaPods/Xcodeproj.svg?style=flat)](https://codeclimate.com/github/CocoaPods/Xcodeproj)
5
- [![Code Climate](https://img.shields.io/codeclimate/maintainability/CocoaPods/Xcodeproj.svg?style=flat&label=code%20climate)](https://codeclimate.com/github/CocoaPods/Xcodeproj)
3
+ [![Build Status](https://img.shields.io/github/workflow/status/CocoaPods/Xcodeproj/Specs)](https://github.com/CocoaPods/Xcodeproj/actions)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/40ae104586c859d3581e/maintainability)](https://codeclimate.com/github/CocoaPods/Xcodeproj/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/40ae104586c859d3581e/test_coverage)](https://codeclimate.com/github/CocoaPods/Xcodeproj/test_coverage)
6
6
 
7
7
  Xcodeproj lets you create and modify Xcode projects from [Ruby][ruby].
8
8
  Script boring management tasks or build Xcode-friendly libraries. Also includes
@@ -64,6 +64,7 @@ project.targets.each do |target|
64
64
  config.build_settings['MY_CUSTOM_FLAG'] ||= 'TRUE'
65
65
  end
66
66
  end
67
+ project.save
67
68
  ```
68
69
 
69
70
  ## Command Line Tool
@@ -33,11 +33,14 @@ module Xcodeproj
33
33
  elsif projects.size > 1
34
34
  raise Informative, 'There are more than one Xcode project documents ' \
35
35
  'in the current working directory. Please specify ' \
36
- 'which to use with the `--project` option.'
36
+ 'the project as the first argument, or specify ' \
37
+ 'which to use with the --project option if using ' \
38
+ 'target-diff.'
37
39
  else
38
40
  raise Informative, 'No Xcode project document found in the current ' \
39
- 'working directory. Please specify which to use ' \
40
- 'with the `--project` option.'
41
+ 'working directory. Please specify the project ' \
42
+ 'as the first argument, or specify which to use ' \
43
+ 'with the --project option if using target-diff.' \
41
44
  end
42
45
  @xcodeproj_path = Pathname.new(xcodeproj_path).expand_path
43
46
  end
@@ -32,15 +32,15 @@ module Xcodeproj
32
32
 
33
33
  # @return [String] The last known object version to Xcodeproj.
34
34
  #
35
- LAST_KNOWN_OBJECT_VERSION = 55
35
+ LAST_KNOWN_OBJECT_VERSION = 56
36
36
 
37
37
  # @return [String] The last known Xcode version to Xcodeproj.
38
38
  #
39
- LAST_UPGRADE_CHECK = '1240'
39
+ LAST_UPGRADE_CHECK = '1300'
40
40
 
41
41
  # @return [String] The last known Xcode version to Xcodeproj.
42
42
  #
43
- LAST_SWIFT_UPGRADE_CHECK = '1240'
43
+ LAST_SWIFT_UPGRADE_CHECK = '1300'
44
44
 
45
45
  # @return [String] The version of `.xcscheme` files supported by Xcodeproj
46
46
  #
@@ -128,6 +128,7 @@ module Xcodeproj
128
128
  # @return [Hash] The compatibility version string for different object versions.
129
129
  #
130
130
  COMPATIBILITY_VERSION_BY_OBJECT_VERSION = {
131
+ 56 => 'Xcode 14.0',
131
132
  55 => 'Xcode 13.0',
132
133
  54 => 'Xcode 12.0',
133
134
  53 => 'Xcode 11.4',
@@ -113,8 +113,8 @@ module Xcodeproj
113
113
  ensure_class(value_2, Array)
114
114
  return nil if value_1 == value_2
115
115
 
116
- new_objects_value_1 = (value_1 - value_2)
117
- new_objects_value_2 = (value_2 - value_1)
116
+ new_objects_value_1 = array_non_unique_diff(value_1, value_2)
117
+ new_objects_value_2 = array_non_unique_diff(value_2, value_1)
118
118
  return nil if value_1.empty? && value_2.empty?
119
119
 
120
120
  matched_diff = {}
@@ -234,6 +234,37 @@ module Xcodeproj
234
234
  raise "Wrong type `#{object.inspect}`" unless object.is_a?(klass)
235
235
  end
236
236
 
237
+ # Returns the difference between two arrays, taking into account the number of times an element
238
+ # repeats in both arrays.
239
+ #
240
+ # @param [Array] value_1
241
+ # First array to the difference operation.
242
+ #
243
+ # @param [Array] value_2
244
+ # Second array to the difference operation.
245
+ #
246
+ # @return [Array]
247
+ #
248
+ def self.array_non_unique_diff(value_1, value_2)
249
+ value_2_elements_by_count = value_2.reduce({}) do |hash, element|
250
+ updated_element_hash = hash.key?(element) ? { element => hash[element] + 1 } : { element => 1 }
251
+ hash.merge(updated_element_hash)
252
+ end
253
+
254
+ value_1_elements_by_deletions =
255
+ value_1.to_set.map do |element|
256
+ times_to_delete_element = value_2_elements_by_count[element] || 0
257
+ next [element, times_to_delete_element]
258
+ end.to_h
259
+
260
+ value_1.select do |element|
261
+ if value_1_elements_by_deletions[element] > 0
262
+ value_1_elements_by_deletions[element] -= 1
263
+ next false
264
+ end
265
+ next true
266
+ end
267
+ end
237
268
  #-------------------------------------------------------------------------#
238
269
  end
239
270
  end
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '1.21.0'.freeze unless defined? Xcodeproj::VERSION
4
+ VERSION = '1.22.0'.freeze unless defined? Xcodeproj::VERSION
5
5
  end
@@ -12,7 +12,7 @@ module Xcodeproj
12
12
 
13
13
  # @!group Attributes
14
14
 
15
- # @return [String] the name of the Target.
15
+ # @return [String] the name of the configuration.
16
16
  #
17
17
  attribute :name, String
18
18
 
@@ -17,6 +17,13 @@ module Xcodeproj
17
17
  #
18
18
  attribute :compiler_spec, String
19
19
 
20
+ # @return [String] the discovered dependency file to use.
21
+ #
22
+ # @example
23
+ # `$(DERIVED_FILES_DIR)/$(INPUT_FILE_NAME).d`.
24
+ #
25
+ attribute :dependency_file, String
26
+
20
27
  # @return [String] the type of the files that should be processed by
21
28
  # this rule.
22
29
  #
@@ -313,8 +313,7 @@ module Xcodeproj
313
313
  end
314
314
 
315
315
  # In addition to removing the file reference, this will also remove any
316
- # items related to this reference in case it represents an external
317
- # Xcode project.
316
+ # items related to this reference.
318
317
  #
319
318
  # @see AbstractObject#remove_from_project
320
319
  #
@@ -327,6 +326,8 @@ module Xcodeproj
327
326
  project_reference[:product_group].remove_from_project
328
327
  project.root_object.project_references.delete(project_reference)
329
328
  end
329
+
330
+ build_files.each(&:remove_from_project)
330
331
  super
331
332
  end
332
333
 
@@ -441,13 +441,32 @@ module Xcodeproj
441
441
  result = File.basename(x.display_name.downcase, '.*') <=> File.basename(y.display_name.downcase, '.*')
442
442
  if result.zero?
443
443
  result = File.extname(x.display_name.downcase) <=> File.extname(y.display_name.downcase)
444
- if result.zero?
444
+ if result.zero? && !(x.path.nil? || y.path.nil?)
445
445
  result = x.path.downcase <=> y.path.downcase
446
446
  end
447
447
  end
448
448
  result
449
449
  end
450
450
  end
451
+
452
+ # @return [Array<PBXBuildFile>] the build files associated with the
453
+ # current reference proxy.
454
+ #
455
+ def build_files
456
+ referrers.grep(PBXBuildFile)
457
+ end
458
+
459
+ # In addition to removing the reference proxy, this will also remove any
460
+ # items related to this reference.
461
+ #
462
+ # @see AbstractObject#remove_from_project
463
+ #
464
+ # @return [void]
465
+ #
466
+ def remove_from_project
467
+ build_files.each(&:remove_from_project)
468
+ super
469
+ end
451
470
  end
452
471
 
453
472
  #-----------------------------------------------------------------------#
@@ -61,6 +61,25 @@ module Xcodeproj
61
61
  return path if path
62
62
  super
63
63
  end
64
+
65
+ # @return [Array<PBXBuildFile>] the build files associated with the
66
+ # current reference proxy.
67
+ #
68
+ def build_files
69
+ referrers.grep(PBXBuildFile)
70
+ end
71
+
72
+ # In addition to removing the reference proxy, this will also remove any
73
+ # items related to this reference.
74
+ #
75
+ # @see AbstractObject#remove_from_project
76
+ #
77
+ # @return [void]
78
+ #
79
+ def remove_from_project
80
+ build_files.each(&:remove_from_project)
81
+ super
82
+ end
64
83
  end
65
84
  end
66
85
  end
@@ -30,9 +30,14 @@ module Xcodeproj
30
30
  #
31
31
  attribute :platform_filter, String
32
32
 
33
- # @return [String] the product reference for this target dependency.
33
+ # @return [Array<String>] the platform filters for this target dependency.
34
34
  #
35
- attribute :product_ref, String
35
+ attribute :platform_filters, Array
36
+
37
+ # @return [XCSwiftPackageProductDependency] the Swift Package product
38
+ # for this target dependency.
39
+ #
40
+ has_one :product_ref, XCSwiftPackageProductDependency
36
41
 
37
42
  public
38
43
 
@@ -45,20 +50,22 @@ module Xcodeproj
45
50
  return name if name
46
51
  return target.name if target
47
52
  return target_proxy.remote_info if target_proxy
53
+ return product_ref.product_name if product_ref
48
54
  end
49
55
 
50
56
  def ascii_plist_annotation
51
57
  " #{isa} "
52
58
  end
53
59
 
54
- # @return [String] uuid of the target, if the dependency
55
- # is a native target, otherwise the uuid of the
56
- # target in the sub-project if the dependency is
57
- # a target proxy
60
+ # @return [String] the uuid of the target if the dependency is a native
61
+ # target, the uuid of the target in the sub-project if the
62
+ # dependency is a target proxy, nil if the dependency is a Swift
63
+ # Package.
58
64
  #
59
65
  def native_target_uuid
60
66
  return target.uuid if target
61
67
  return target_proxy.remote_global_id_string if target_proxy
68
+ return nil if product_ref
62
69
  raise "Expected target or target_proxy, from which to fetch a uuid for target '#{display_name}'." \
63
70
  "Find and clear the PBXTargetDependency entry with uuid '#{@uuid}' in your .xcodeproj."
64
71
  end
@@ -151,6 +151,44 @@ module Xcodeproj
151
151
  arguments
152
152
  end
153
153
 
154
+ # @return [Array<BuildableReference>]
155
+ # The list of BuildableReference (code coverage targets) associated with this Test Action
156
+ #
157
+ def code_coverage_targets
158
+ return [] unless @xml_element.elements['CodeCoverageTargets']
159
+
160
+ @xml_element.elements['CodeCoverageTargets'].get_elements('BuildableReference').map do |node|
161
+ BuildableReference.new(node)
162
+ end
163
+ end
164
+
165
+ # @param [Array<BuildableReference>] buildable_references
166
+ # Sets the list of BuildableReference (code coverage targets) associated with this Test Action
167
+ #
168
+ def code_coverage_targets=(buildable_references)
169
+ @xml_element.attributes['onlyGenerateCoverageForSpecifiedTargets'] = bool_to_string(true)
170
+
171
+ @xml_element.delete_element('CodeCoverageTargets')
172
+ coverage_targets_element = @xml_element.add_element('CodeCoverageTargets')
173
+ buildable_references.each do |reference|
174
+ coverage_targets_element.add_element(reference.xml_element)
175
+ end
176
+
177
+ code_coverage_targets
178
+ end
179
+
180
+ # @param [BuildableReference] buildable_reference
181
+ # Add a BuildableReference (code coverage target) to this Test Action
182
+ #
183
+ def add_code_coverage_target(buildable_reference)
184
+ @xml_element.attributes['onlyGenerateCoverageForSpecifiedTargets'] = bool_to_string(true)
185
+
186
+ coverage_targets_element = @xml_element.elements['CodeCoverageTargets'] || @xml_element.add_element('CodeCoverageTargets')
187
+ coverage_targets_element.add_element(buildable_reference.xml_element)
188
+
189
+ code_coverage_targets
190
+ end
191
+
154
192
  #-------------------------------------------------------------------------#
155
193
 
156
194
  class TestableReference < XMLElementWrapper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.0
4
+ version: 1.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-09 00:00:00.000000000 Z
11
+ date: 2022-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: atomos
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.0.3
204
+ rubygems_version: 3.1.6
205
205
  signing_key:
206
206
  specification_version: 3
207
207
  summary: Create and modify Xcode projects from Ruby.