xcodeproj 1.7.0 → 1.8.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
- SHA256:
3
- metadata.gz: a926103d6bbeeea7900326a53221df41a158228484f36dce922c54eadfa741b1
4
- data.tar.gz: d15b7d1db2f2ad119b4660a5cad26476930866dd1bee818e770ce8d2c1b8ee4e
2
+ SHA1:
3
+ metadata.gz: dd5a8807aed9829a9a1e355790100434f4df1fd7
4
+ data.tar.gz: 15e7c38281fb55f32e2a473e1badf6d806d9063e
5
5
  SHA512:
6
- metadata.gz: 4886ecf3b87f33ab29072b8ae56b22bfc7810cd0feb9a460449c612d9c947befb7a101e56ffd3dadc03bda4268057f4a48d46cb2ad2dade6a645aa0a65ab5dff
7
- data.tar.gz: 85e155a16497eab7dafc72b1c4732cf32ed1ecf90cb10d08d144eea810dd79b99193782c5031609cb5be17e2f961526b4b087eb1196ae971e067083e2f81ab94
6
+ metadata.gz: ae80f793ecc1635660a7802304547540c9a1e3eb2e8b54a0572acfa8eb3c3069edd3c0302360393041da28026eb77bbf3a5f3e263f72c040ce0c149fb621c2c4
7
+ data.tar.gz: 531fa9d52e9be2918b113f6603f7d5382ff00eb707de7cc34b70ed956c65f759420292cb4552611d839ad8bb6031d028c4bc91fc1ac3894ee46e40bf6b3a86fb
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '1.7.0'.freeze unless defined? Xcodeproj::VERSION
4
+ VERSION = '1.8.0'.freeze unless defined? Xcodeproj::VERSION
5
5
  end
@@ -388,7 +388,24 @@ module Xcodeproj
388
388
  # @return [void]
389
389
  #
390
390
  def predictabilize_uuids
391
- UUIDGenerator.new(self).generate!
391
+ UUIDGenerator.new([self]).generate!
392
+ end
393
+
394
+ # Replaces all the UUIDs in the list of provided projects with deterministic MD5 checksums.
395
+ #
396
+ # @param [Array<Project>] projects
397
+ #
398
+ # @note The current sorting of the project is taken into account when
399
+ # generating the new UUIDs.
400
+ #
401
+ # @note This method should only be used for entirely machine-generated
402
+ # projects, as true UUIDs are useful for tracking changes in the
403
+ # project.
404
+ #
405
+ # @return [void]
406
+ #
407
+ def self.predictabilize_uuids(projects)
408
+ UUIDGenerator.new(projects).generate!
392
409
  end
393
410
 
394
411
  public
@@ -279,16 +279,14 @@ module Xcodeproj
279
279
 
280
280
  # @return [String] the actual script to perform.
281
281
  #
282
- # @note Defaults to the empty string.
282
+ # @note Defaults to a comment string.
283
283
  #
284
- attribute :shell_script, String, ''
284
+ attribute :shell_script, String, "# Type a script or drag a script file from your workspace to insert its path.\n"
285
285
 
286
286
  # @return [String] whether or not the ENV variables should be shown in
287
287
  # the build log.
288
288
  #
289
- # @note Defaults to true (`1`).
290
- #
291
- attribute :show_env_vars_in_log, String, '1'
289
+ attribute :show_env_vars_in_log, String
292
290
  end
293
291
 
294
292
  #-----------------------------------------------------------------------#
@@ -177,9 +177,7 @@ module Xcodeproj
177
177
  ref = new_file_reference(group, path, source_tree)
178
178
  ref.include_in_index = nil
179
179
 
180
- product_group_ref = group.project.new(PBXGroup)
181
- product_group_ref.name = 'Products'
182
- product_group_ref.source_tree = '<group>'
180
+ product_group_ref = find_products_group_ref(group, true)
183
181
 
184
182
  subproj = Project.open(path)
185
183
  subproj.products_group.files.each do |product_reference|
@@ -230,6 +228,12 @@ module Xcodeproj
230
228
  end
231
229
  end
232
230
 
231
+ def find_products_group_ref(group, should_create = false)
232
+ product_group_ref =
233
+ (group.project.root_object.product_ref_group ||= group.project.main_group.find_subpath('Products', should_create))
234
+ product_group_ref
235
+ end
236
+
233
237
  #-------------------------------------------------------------------#
234
238
  end
235
239
  end
@@ -356,7 +356,7 @@ module Xcodeproj
356
356
  end
357
357
  alias_method :add_system_frameworks, :add_system_framework
358
358
 
359
- # Adds a file reference for one or more system libraries to the project
359
+ # Adds a file reference for one or more system dylib libraries to the project
360
360
  # if needed and adds them to the Frameworks build phases.
361
361
  #
362
362
  # @param [Array<String>, String] name
@@ -365,8 +365,13 @@ module Xcodeproj
365
365
  # @return [void]
366
366
  #
367
367
  def add_system_library(names)
368
+ add_system_library_extension(names, 'dylib')
369
+ end
370
+ alias_method :add_system_libraries, :add_system_library
371
+
372
+ def add_system_library_extension(names, extension)
368
373
  Array(names).each do |name|
369
- path = "usr/lib/lib#{name}.dylib"
374
+ path = "usr/lib/lib#{name}.#{extension}"
370
375
  files = project.frameworks_group.files
371
376
  unless reference = files.find { |ref| ref.path == path }
372
377
  reference = project.frameworks_group.new_file(path, :sdk_root)
@@ -375,7 +380,20 @@ module Xcodeproj
375
380
  reference
376
381
  end
377
382
  end
378
- alias_method :add_system_libraries, :add_system_library
383
+ private :add_system_library_extension
384
+
385
+ # Adds a file reference for one or more system tbd libraries to the project
386
+ # if needed and adds them to the Frameworks build phases.
387
+ #
388
+ # @param [Array<String>, String] name
389
+ # The name or the list of the names of the libraries.
390
+ #
391
+ # @return [void]
392
+ #
393
+ def add_system_library_tbd(names)
394
+ add_system_library_extension(names, 'tbd')
395
+ end
396
+ alias_method :add_system_libraries_tbd, :add_system_library_tbd
379
397
 
380
398
  public
381
399
 
@@ -3,45 +3,55 @@ module Xcodeproj
3
3
  class UUIDGenerator
4
4
  require 'digest'
5
5
 
6
- def initialize(project)
7
- @project = project
8
- @new_objects_by_uuid = {}
6
+ def initialize(projects)
7
+ @projects = Array(projects)
9
8
  @paths_by_object = {}
10
9
  end
11
10
 
12
11
  def generate!
13
- all_objects = @project.objects
14
- generate_paths(@project.root_object)
15
- switch_uuids(all_objects)
16
- verify_no_duplicates!(all_objects)
17
- fixup_uuid_references
18
- @project.instance_variable_set(:@generated_uuids, @project.instance_variable_get(:@available_uuids))
19
- @project.instance_variable_set(:@objects_by_uuid, @new_objects_by_uuid)
12
+ generate_all_paths_by_objects(@projects)
13
+
14
+ new_objects_by_project = Hash[@projects.map do |project|
15
+ [project, switch_uuids(project)]
16
+ end]
17
+ all_new_objects_by_project = new_objects_by_project.values.flat_map(&:values)
18
+ all_objects_by_uuid = @projects.map(&:objects_by_uuid).inject(:merge)
19
+ all_objects = @projects.flat_map(&:objects)
20
+ verify_no_duplicates!(all_objects, all_new_objects_by_project)
21
+ @projects.each { |project| fixup_uuid_references(project, all_objects_by_uuid) }
22
+ new_objects_by_project.each do |project, new_objects_by_uuid|
23
+ project.instance_variable_set(:@generated_uuids, project.instance_variable_get(:@available_uuids))
24
+ project.instance_variable_set(:@objects_by_uuid, new_objects_by_uuid)
25
+ end
20
26
  end
21
27
 
22
28
  private
23
29
 
24
30
  UUID_ATTRIBUTES = [:remote_global_id_string, :container_portal, :target_proxy].freeze
25
31
 
26
- def verify_no_duplicates!(all_objects)
27
- duplicates = all_objects - @new_objects_by_uuid.values
32
+ def verify_no_duplicates!(all_objects, all_new_objects)
33
+ duplicates = all_objects - all_new_objects
28
34
  UserInterface.warn "[Xcodeproj] Generated duplicate UUIDs:\n\n" <<
29
35
  duplicates.map { |d| "#{d.isa} -- #{@paths_by_object[d]}" }.join("\n") unless duplicates.empty?
30
36
  end
31
37
 
32
- def fixup_uuid_references
38
+ def fixup_uuid_references(target_project, all_objects_by_uuid)
33
39
  fixup = ->(object, attr) do
34
- if object.respond_to?(attr) && link = @project.objects_by_uuid[object.send(attr)]
40
+ if object.respond_to?(attr) && link = all_objects_by_uuid[object.send(attr)]
35
41
  object.send(:"#{attr}=", link.uuid)
36
42
  end
37
43
  end
38
- @project.objects.each do |object|
44
+ target_project.objects.each do |object|
39
45
  UUID_ATTRIBUTES.each do |attr|
40
46
  fixup[object, attr]
41
47
  end
42
48
  end
43
49
  end
44
50
 
51
+ def generate_all_paths_by_objects(projects)
52
+ projects.each { |project| generate_paths(project.root_object, project.path.basename.to_s) }
53
+ end
54
+
45
55
  def generate_paths(object, path = '')
46
56
  existing = @paths_by_object[object] || path
47
57
  return existing if @paths_by_object.key?(object)
@@ -67,13 +77,13 @@ module Xcodeproj
67
77
  end
68
78
  end
69
79
 
70
- def switch_uuids(objects)
71
- @project.mark_dirty!
72
- objects.each do |object|
80
+ def switch_uuids(project)
81
+ project.mark_dirty!
82
+ project.objects.each_with_object({}) do |object, hash|
73
83
  next unless path = @paths_by_object[object]
74
84
  uuid = uuid_for_path(path)
75
85
  object.instance_variable_set(:@uuid, uuid)
76
- @new_objects_by_uuid[uuid] = object
86
+ hash[uuid] = object
77
87
  end
78
88
  end
79
89
 
@@ -193,9 +193,9 @@ module Xcodeproj
193
193
 
194
194
  entry.build_for_testing = true
195
195
  entry.build_for_running = build_for_running
196
- entry.build_for_profiling = true
197
- entry.build_for_archiving = true
198
- entry.build_for_analyzing = true
196
+ entry.build_for_profiling = build_for_running
197
+ entry.build_for_archiving = build_for_running
198
+ entry.build_for_analyzing = build_for_running
199
199
 
200
200
  build_action.add_entry(entry)
201
201
  end
@@ -47,6 +47,40 @@ module Xcodeproj
47
47
  @xml_element.attributes['allowLocationSimulation'] = bool_to_string(flag)
48
48
  end
49
49
 
50
+ # @return [Bool]
51
+ # Whether this Build Action should disable detection of UI API misuse
52
+ # from background threads
53
+ #
54
+ def disable_main_thread_checker?
55
+ string_to_bool(@xml_element.attributes['disableMainThreadChecker'])
56
+ end
57
+
58
+ # @param [Bool] flag
59
+ # Set whether this Build Action should disable detection of UI API misuse
60
+ # from background threads
61
+ #
62
+ def disable_main_thread_checker=(flag)
63
+ @xml_element.attributes['disableMainThreadChecker'] = bool_to_string(flag)
64
+ end
65
+
66
+ # @return [Bool]
67
+ # Whether UI API misuse from background threads detection should pause execution.
68
+ # This flag is ignored when the thread checker disabled
69
+ # ([disable_main_thread_checker] flag).
70
+ #
71
+ def stop_on_every_main_thread_checker_issue?
72
+ string_to_bool(@xml_element.attributes['stopOnEveryMainThreadCheckerIssue'])
73
+ end
74
+
75
+ # @param [Bool] flag
76
+ # Set whether UI API misuse from background threads detection should pause execution.
77
+ # This flag is ignored when the thread checker disabled
78
+ # ([disable_main_thread_checker] flag).
79
+ #
80
+ def stop_on_every_main_thread_checker_issue=(flag)
81
+ @xml_element.attributes['stopOnEveryMainThreadCheckerIssue'] = bool_to_string(flag)
82
+ end
83
+
50
84
  # @return [String]
51
85
  # The launch automatically substyle
52
86
  #
@@ -35,6 +35,22 @@ module Xcodeproj
35
35
  @xml_element.attributes['shouldUseLaunchSchemeArgsEnv'] = bool_to_string(flag)
36
36
  end
37
37
 
38
+ # @return [Bool]
39
+ # Whether this Test Action should disable detection of UI API misuse
40
+ # from background threads
41
+ #
42
+ def disable_main_thread_checker?
43
+ string_to_bool(@xml_element.attributes['disableMainThreadChecker'])
44
+ end
45
+
46
+ # @param [Bool] flag
47
+ # Set whether this Test Action should disable detection of UI API misuse
48
+ # from background threads
49
+ #
50
+ def disable_main_thread_checker=(flag)
51
+ @xml_element.attributes['disableMainThreadChecker'] = bool_to_string(flag)
52
+ end
53
+
38
54
  # @return [Bool]
39
55
  # Whether Clang Code Coverage is enabled ('Gather coverage data' turned ON)
40
56
  #
@@ -47,9 +47,22 @@ module Xcodeproj
47
47
  #
48
48
  def self.from_node(xml_node)
49
49
  type, path = xml_node.attribute('location').value.split(':', 2)
50
+ path = prepend_parent_path(xml_node, path)
50
51
  new(path, type)
51
52
  end
52
53
 
54
+ def self.prepend_parent_path(xml_node, path)
55
+ if !xml_node.parent.nil? && (xml_node.parent.name == 'Group')
56
+ group = GroupReference.from_node(xml_node.parent)
57
+ if !group.location.nil? && !group.location.empty?
58
+ path = '' if path.nil?
59
+ path = File.join(group.location, path)
60
+ end
61
+ end
62
+
63
+ path
64
+ end
65
+
53
66
  # @return [REXML::Element] the XML representation of the file reference.
54
67
  #
55
68
  def to_node
@@ -17,25 +17,31 @@ module Xcodeproj
17
17
  #
18
18
  attr_reader :type
19
19
 
20
+ # @return [String] the location of the group on disk
21
+ #
22
+ attr_reader :location
23
+
20
24
  # @param [#to_s] name @see name
21
25
  # @param [#to_s] type @see type
26
+ # @param [#to_s] location @see location
22
27
  #
23
- def initialize(name, type = 'container')
28
+ def initialize(name, type = 'container', location = '')
24
29
  @name = name.to_s
25
30
  @type = type.to_s
31
+ @location = location.to_s
26
32
  end
27
33
 
28
34
  # @return [Bool] Whether a group reference is equal to another.
29
35
  #
30
36
  def ==(other)
31
- name == other.name && type == other.type
37
+ name == other.name && type == other.type && location == other.location
32
38
  end
33
39
  alias_method :eql?, :==
34
40
 
35
41
  # @return [Fixnum] A hash identical for equals objects.
36
42
  #
37
43
  def hash
38
- [name, type].hash
44
+ [name, type, location].hash
39
45
  end
40
46
 
41
47
  # Returns a group reference given XML representation.
@@ -46,16 +52,18 @@ module Xcodeproj
46
52
  # @return [GroupReference] The new group reference instance.
47
53
  #
48
54
  def self.from_node(xml_node)
49
- type = xml_node.attribute('location').value.split(':', 2).first
55
+ location_array = xml_node.attribute('location').value.split(':', 2)
56
+ type = location_array.first
57
+ location = location_array[1] || ''
50
58
  name = xml_node.attribute('name').value
51
- new(name, type)
59
+ new(name, type, location)
52
60
  end
53
61
 
54
62
  # @return [REXML::Element] the XML representation of the group reference.
55
63
  #
56
64
  def to_node
57
65
  REXML::Element.new('Group').tap do |element|
58
- element.add_attribute('location', "#{type}:")
66
+ element.add_attribute('location', "#{type}:#{location}")
59
67
  element.add_attribute('name', "#{name}")
60
68
  end
61
69
  end
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.7.0
4
+ version: 1.8.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: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2019-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: atomos
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.7.7
184
+ rubygems_version: 2.6.14
185
185
  signing_key:
186
186
  specification_version: 3
187
187
  summary: Create and modify Xcode projects from Ruby.