Class: Pod::Installer::PodSourceInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-matchup/Integration.rb

Instance Method Summary collapse

Instance Method Details

#install_for_prebuild!(standard_sanbox) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cocoapods-binary-matchup/Integration.rb', line 25

def install_for_prebuild!(standard_sanbox)
    return if standard_sanbox.local? self.name
    UI.puts "install_for_prebuild! start: #{self.name}"
    
    # 获取pod版本信息
    pod_version = Pod::PrebuildCache::Cache.get_pod_version(standard_sanbox, self.name)
    target_folder = standard_sanbox.pod_dir(self.name)
    target_folder.rmtree if target_folder.exist?
    
    # 1. 首先尝试从缓存恢复
    if Pod::PrebuildCache::Cache.copy_from_cache_if_exists(self.name, pod_version, target_folder.to_s)
        UI.puts "📦 Successfully restored #{self.name} (#{pod_version}) from cache"
        return
    end
    
    # 2. 如果缓存不存在,从预构建目录拷贝
    prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
    real_file_folder = prebuild_sandbox.framework_folder_path_for_pod_name(self.name)
    
    if real_file_folder.exist?
        # 拷贝到pods目录
        FileUtils.cp_r(real_file_folder, target_folder, :remove_destination => true)
        UI.puts "📦 Copied prebuilt files for #{self.name}: #{real_file_folder} -> #{target_folder}"
        
        # 3. 同时保存到缓存(如果缓存不存在)
        Pod::PrebuildCache::Cache.save_to_cache(self.name, pod_version, target_folder.to_s)
    else
        UI.puts "⚠️  Warning: Prebuilt files not found for #{self.name} at #{real_file_folder}"
        # 如果预构建文件不存在,创建空目录避免错误
        target_folder.mkpath
    end
end