Module: Pod::PodGenerate::Patches::ProjectWriterPatch::IncrementalAndParallelSave

Defined in:
lib/cocoapods-podgenerate/patches/project_writer_patch.rb

Instance Method Summary collapse

Instance Method Details

#initialize(sandbox, projects, pod_target_installation_results, installation_options) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/cocoapods-podgenerate/patches/project_writer_patch.rb', line 29

def initialize(sandbox, projects, pod_target_installation_results, installation_options)
  super
  @project_digests = {}
  @projects = projects
  @sort_needed = {}
  compute_initial_digests
end

#save_projects(projects) ⇒ Object

── Optimization 1: SHA256 skip + parallel save ──



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/cocoapods-podgenerate/patches/project_writer_patch.rb', line 51

def save_projects(projects)
  # Filter: skip projects whose pbxproj is unchanged
  to_save = projects.select do |project|
    if project_unchanged?(project)
      Pod::UI.message "- Skipping unchanged project #{UI.path project.path}"
      false
    else
      true
    end
  end
  return if to_save.empty?

  # Sort each project
  to_save.each { |p| p.sort(:groups_position => :below) if needs_sort?(p) }

  # Parallel save (safe: each xcodeproj is an independent directory)
  if to_save.size > 1
    Pod::UI.message "- Saving #{to_save.size} projects in parallel"
    threads = to_save.map do |project|
      Thread.new do
        begin
          Pod::UI.message "- Writing Xcode project file to #{UI.path project.path}"
          project.save
          update_digest(project)
        rescue StandardError => e
          Pod::UI.warn "[cocoapods-podgenerate] Parallel save error: #{e.message}"
        end
      end
    end
    threads.each(&:join)
  else
    Pod::UI.message "- Writing Xcode project file to #{UI.path to_save.first.path}" do
      to_save.first.save
      update_digest(to_save.first)
    end
  end
end

#write!Object

── Optimizations 3+4+2: Parallel write! with parallel cleanup + schemes + save ──



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cocoapods-podgenerate/patches/project_writer_patch.rb', line 38

def write!
  # Parallel cleanup (each project is independent)
  parallel_cleanup_projects(@projects)

  # Parallel recreate_user_schemes (each project is independent)
  parallel_recreate_user_schemes(@projects)

  yield if block_given?

  save_projects(@projects)
end