class Pod::Installer

Public Instance Methods

create_pod_installer(pod_name) click to toggle source
# File lib/cocoapods-imy-bin/native/installer.rb, line 10
def create_pod_installer(pod_name)
  installer = old_create_pod_installer(pod_name)
  installer.installation_options = installation_options
  installer
end
Also aliased as: old_create_pod_installer
install_pod_sources() click to toggle source
# File lib/cocoapods-imy-bin/native/installer.rb, line 17
def install_pod_sources
  if installation_options.install_with_multi_threads
    if Pod.match_version?('~> 1.4.0')
      install_pod_sources_for_version_in_1_4_0
    elsif Pod.match_version?('~> 1.5')
      install_pod_sources_for_version_above_1_5_0
    else
      old_install_pod_sources
    end
  else
    old_install_pod_sources
    end
end
Also aliased as: old_install_pod_sources
install_pod_sources_for_version_above_1_5_0() click to toggle source
# File lib/cocoapods-imy-bin/native/installer.rb, line 55
def install_pod_sources_for_version_above_1_5_0
  @installed_specs = []
  pods_to_install = sandbox_state.added | sandbox_state.changed
  title_options = { verbose_prefix: '-> '.green }
  # 多进程下载,多线程时 log 会显著交叉,多进程好点,但是多进程需要利用文件锁对 cache 进行保护
  # in_processes: 10
  Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
    if pods_to_install.include?(spec.name)
      if sandbox_state.changed.include?(spec.name) && sandbox.manifest
        current_version = spec.version
        previous_version = sandbox.manifest.version(spec.name)
        has_changed_version = current_version != previous_version
        current_repo = analysis_result.specs_by_source.detect do |key, values|
          break key if values.map(&:name).include?(spec.name)
        end
        current_repo &&= current_repo.url || current_repo.name
        previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
        has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
        title = "Installing #{spec.name} #{spec.version}"
        if has_changed_version && has_changed_repo
          title += " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
          end
        if has_changed_version && !has_changed_repo
          title += " (was #{previous_version})"
          end
        if !has_changed_version && has_changed_repo
          title += " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
          end
      else
        title = "Installing #{spec}"
      end
      UI.titled_section(title.green, title_options) do
        install_source_of_pod(spec.name)
      end
    else
      UI.titled_section("Using #{spec}", title_options) do
        create_pod_installer(spec.name)
      end
    end
  end
end
install_pod_sources_for_version_in_1_4_0() click to toggle source

rewrite install_pod_sources

# File lib/cocoapods-imy-bin/native/installer.rb, line 32
def install_pod_sources_for_version_in_1_4_0
  @installed_specs = []
  pods_to_install = sandbox_state.added | sandbox_state.changed
  title_options = { verbose_prefix: '-> '.green }
  Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
    if pods_to_install.include?(spec.name)
      if sandbox_state.changed.include?(spec.name) && sandbox.manifest
        previous = sandbox.manifest.version(spec.name)
        title = "Installing #{spec.name} #{spec.version} (was #{previous})"
      else
        title = "Installing #{spec}"
      end
      UI.titled_section(title.green, title_options) do
        install_source_of_pod(spec.name)
      end
    else
      UI.titled_section("Using #{spec}", title_options) do
        create_pod_installer(spec.name)
      end
    end
  end
end
old_create_pod_installer(pod_name)
old_install_pod_sources()
Alias for: install_pod_sources
old_write_lockfiles()
Alias for: write_lockfiles
write_lockfiles() click to toggle source
# File lib/cocoapods-imy-bin/native/installer.rb, line 98
def write_lockfiles
  old_write_lockfiles
  if File.exist?('Podfile_local')

    project = Xcodeproj::Project.open(config.sandbox.project_path)
    #获取主group
    group = project.main_group
    group.set_source_tree('SOURCE_ROOT')
    #向group中添加 文件引用
    file_ref = group.new_reference(config.sandbox.root + '../Podfile_local')
    #podfile_local排序
    podfile_local_group = group.children.last
    group.children.pop
    group.children.unshift(podfile_local_group)
    #保存
    project.save
  end
end
Also aliased as: old_write_lockfiles