Class: Pod::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-tj/native/analyzer.rb,
lib/cocoapods-tj/native/installer.rb,
lib/cocoapods-tj/native/sandbox_analyzer.rb,
lib/cocoapods-tj/native/target_validator.rb,
lib/cocoapods-tj/native/installation_options.rb,
lib/cocoapods-tj/native/pod_source_installer.rb,
lib/cocoapods-tj/native/pod_target_installer.rb

Defined Under Namespace

Classes: Analyzer, InstallationOptions, PodSourceInstaller, Xcode

Instance Method Summary collapse

Instance Method Details

#create_pod_installer(pod_name) ⇒ Object



12
13
14
15
16
17
# File 'lib/cocoapods-tj/native/installer.rb', line 12

def create_pod_installer(pod_name)
  installer = old_create_pod_installer(pod_name)
  #报错,暂时先注释掉
  # installer.installation_options = installation_options
  installer
end

#install_pod_sourcesObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cocoapods-tj/native/installer.rb', line 27

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

#install_pod_sources_for_version_above_1_5_0Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cocoapods-tj/native/installer.rb', line 67

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 }

  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_0Object

rewrite install_pod_sources



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cocoapods-tj/native/installer.rb', line 42

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
      #
      # end
      install_source_of_pod(spec.name)
    else
      create_pod_installer(spec.name)
      # UI.titled_section("Using #{spec}", title_options) do
      #
      # end
    end
  end
end

#old_create_pod_installerObject



11
# File 'lib/cocoapods-tj/native/installer.rb', line 11

alias old_create_pod_installer create_pod_installer

#old_install_pod_sourcesObject



26
# File 'lib/cocoapods-tj/native/installer.rb', line 26

alias old_install_pod_sources install_pod_sources

#old_perform_post_install_actionsObject



19
# File 'lib/cocoapods-tj/native/installer.rb', line 19

alias old_perform_post_install_actions perform_post_install_actions

#perform_post_install_actionsObject



20
21
22
23
24
# File 'lib/cocoapods-tj/native/installer.rb', line 20

def perform_post_install_actions
  old_perform_post_install_actions
  buildTemp = CBin::Config::Builder.instance.root_dir
  buildTemp.rmtree if buildTemp&.exist?
end