Class: Xcodeproj::Project::UUIDGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/xcodeproj/project/uuid_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(projects) ⇒ UUIDGenerator

Returns a new instance of UUIDGenerator.



6
7
8
9
# File 'lib/xcodeproj/project/uuid_generator.rb', line 6

def initialize(projects)
  @projects = Array(projects)
  @paths_by_object = {}
end

Instance Method Details

#generate!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xcodeproj/project/uuid_generator.rb', line 11

def generate!
  generate_all_paths_by_objects(@projects)

  new_objects_by_project = Hash[@projects.map do |project|
    [project, switch_uuids(project)]
  end]
  all_new_objects_by_project = new_objects_by_project.values.flat_map(&:values)
  all_objects_by_uuid = @projects.map(&:objects_by_uuid).inject(:merge)
  all_objects = @projects.flat_map(&:objects)
  verify_no_duplicates!(all_objects, all_new_objects_by_project)
  @projects.each { |project| fixup_uuid_references(project, all_objects_by_uuid) }
  new_objects_by_project.each do |project, new_objects_by_uuid|
    project.instance_variable_set(:@generated_uuids, project.instance_variable_get(:@available_uuids))
    project.instance_variable_set(:@objects_by_uuid, new_objects_by_uuid)
  end
end