class Xcodeproj::Project::UUIDGenerator

def fixup_uuid_references(target_project, all_objects_by_uuid)

def fixup_uuid_references(target_project, all_objects_by_uuid)
  fixup = ->(object, attr) do
    if object.respond_to?(attr) && link = all_objects_by_uuid[object.send(attr)]
      object.send(:"#{attr}=", link.uuid)
    end
  end
  target_project.objects.each do |object|
    UUID_ATTRIBUTES.each do |attr|
      fixup[object, attr]
    end
  end
  if (project_attributes = target_project.root_object.attributes) && project_attributes['TargetAttributes']
    project_attributes['TargetAttributes'] = Hash[project_attributes['TargetAttributes'].map do |target_uuid, attributes|
      if test_target_id = attributes['TestTargetID']
        attributes = attributes.merge('TestTargetID' => all_objects_by_uuid[test_target_id].uuid)
      end
      if target_object = all_objects_by_uuid[target_uuid]
        target_uuid = target_object.uuid
      end
      [target_uuid, attributes]
    end]
  end
end