ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

iOS.CocoaPods.25-issues-pod install: Stuck at "Generating deterministic UUIDs"

2022-09-14 16:00:31  阅读:342  来源: 互联网

标签:Generating end uuid deterministic iOS project objects uuids projects


pod install: Stuck at "Generating deterministic UUIDs"

 

1. Pod Version

$ pod --version 

1.10.1

 

2. "Generating deterministic UUIDs"

2.1 Calling predictabilize_uuids function

 

https://github.com/CocoaPods/CocoaPods/blob/1.10.1/lib/cocoapods/installer.rb#L323

def create_and_save_projects(pod_targets_to_generate, aggregate_targets_to_generate, build_configurations, project_object_version)
// ... ...

        predictabilize_uuids(generated_projects) if installation_options.deterministic_uuids?
        stabilize_target_uuids(generated_projects)

// ... ...

end

 

对应到cocoapods在本地的安装路径为: 

/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb

 

2.2 The predictabilize_uuids function

https://github.com/CocoaPods/CocoaPods/blob/1.10.1/lib/cocoapods/installer.rb#L343

def predictabilize_uuids(projects)
      UI.message('- Generating deterministic UUIDs') { Xcodeproj::Project.predictabilize_uuids(projects) }
end

def stabilize_target_uuids(projects)
      UI.message('- Stabilizing target UUIDs') { TargetUUIDGenerator.new(projects).generate! }
end

 

2.2.1 测量Xcodeproj::Project.predictabilize_uuids(projects)的耗时

在Xcodeproj::Project.predictabilize_uuids(projects)前后输出时间戳到UI(User Interface),如下所示: 

    def predictabilize_uuids(projects)
      UI.message('- Generating deterministic UUIDs') {
                begin_ts = Time.now.strftime '%Y-%m-%d %H:%M:%S' 
                UI.message(begin_ts)
                Xcodeproj::Project.predictabilize_uuids(projects)
                end_ts = Time.now.strftime '%Y-%m-%d %H:%M:%S'
                UI.message(end_ts)
        }
    end

 

"pod install --verbose"的输出为:

Integrating target `ZipArchive`
    Adding Build Phase '[CP] Copy dSYMs' to project.
    Adding Build Phase '[CP] Copy XCFrameworks' to project.
  - Generating deterministic UUIDs
    2022-09-14 10:57:39
    2022-09-14 10:59:05
  - Stabilizing target UUIDs
  - Running post install hooks

 

  

2.3 The message function

https://github.com/CocoaPods/CocoaPods/blob/1.10.1/lib/cocoapods/user_interface.rb#L140

def message(message, verbose_prefix = '', relative_indentation = 2)
        message = verbose_prefix + message if config.verbose?
        puts_indented message if config.verbose?

        self.indentation_level += relative_indentation
        yield if block_given?
ensure
        self.indentation_level -= relative_indentation
end

 

 

yield if block_given?

Ruby.yield-and-block_given

 

2.4 The hot point

"Xcodeproj::Project.predictabilize_uuids(projects)"

https://github.com/CocoaPods/Xcodeproj/blob/1.19.0/lib/xcodeproj/project.rb

 

1     def self.predictabilize_uuids(projects)
2       UUIDGenerator.new(projects).generate!
3     end

  

2.4.1 Class Xcodeproj::Project

https://www.rubydoc.info/github/CocoaPods/Xcodeproj/Xcodeproj/Project

 

2.4.2 UUIDGenerator类的generate!方法

https://github.com/CocoaPods/Xcodeproj/blob/1.19.0/lib/xcodeproj/project/uuid_generator.rb

generate!方法中耗时操作集中在: 

generate_all_paths_by_objects()方法和switch_uuids()方法。

 1       def generate!
 2         generate_all_paths_by_objects(@projects)
 3 
 4         new_objects_by_project = Hash[@projects.map do |project|
 5           [project, switch_uuids(project)]
 6         end]
 7         all_new_objects_by_project = new_objects_by_project.values.flat_map(&:values)
 8         all_objects_by_uuid = @projects.map(&:objects_by_uuid).inject(:merge)
 9         all_objects = @projects.flat_map(&:objects)
10         verify_no_duplicates!(all_objects, all_new_objects_by_project)
11         @projects.each { |project| fixup_uuid_references(project, all_objects_by_uuid) }
12         new_objects_by_project.each do |project, new_objects_by_uuid|
13           project.instance_variable_set(:@generated_uuids, project.instance_variable_get(:@available_uuids))
14           project.instance_variable_set(:@objects_by_uuid, new_objects_by_uuid)
15         end
16       end

 

 

 

generate!方法中调用switch_uuids()方法来计算MD5。

 1       def switch_uuids(project)
 2         project.mark_dirty!
 3         project.objects.each_with_object({}) do |object, hash|
 4           next unless path = @paths_by_object[object]
 5           uuid = uuid_for_path(path)
 6           object.instance_variable_set(:@uuid, uuid)
 7           hash[uuid] = object
 8         end
 9       end
10 
11       def uuid_for_path(path)
12         Digest::MD5.hexdigest(path).upcase
13       end

 

3. 跳过"Generating deterministic UUIDs"

Ref[14]

通过在Podfile中使用Root Option来跳过"Generating deterministic UUIDs"步骤:

install! 'cocoapods',
         :deterministic_uuids => false

: 跳过"Generating deterministic UUIDs"的影响是什么? 

 

 

 

 

 

 


Reference

1. pod install: Stuck at "Generating deterministic UUIDs" #10506 

https://github.com/CocoaPods/CocoaPods/issues/10506

 

2. What Is a UUID and How Are They Generated?

A look at Universally Unique Identifiers

https://betterprogramming.pub/what-is-a-uuid-and-how-are-they-generated-17f0acbd7233

 

3. Deterministic UUIDs #175

https://github.com/CocoaPods/Xcodeproj/issues/175

 

4. install!

https://guides.cocoapods.org/syntax/podfile.html#install_bang

 

标签:Generating,end,uuid,deterministic,iOS,project,objects,uuids,projects
来源: https://www.cnblogs.com/cwgk/p/16582152.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有