Class: Pod::Installer::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-mtxx-bin/native/analyzer.rb,
lib/cocoapods-mtxx-bin/native/sandbox_analyzer.rb

Defined Under Namespace

Classes: SandboxAnalyzer

Instance Method Summary collapse

Instance Method Details

#dependencies_for_specs(specs, platform, all_specs) ⇒ Object



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-mtxx-bin/native/analyzer.rb', line 74

def dependencies_for_specs(specs, platform, all_specs)
  dependent_specs = {
    :debug => Set.new,
    :release => Set.new,
  }

  podfile = Pod::Config.instance.podfile

  if !specs.empty? && !all_specs.empty?
    specs.each do |s|
      s.dependencies(platform).each do |dep|
        # use_binary = podfile.use_binaries? && !podfile.use_source_pods.include?(dep.root_name)
        # key = use_binary ? dep.root_name : dep.name
        all_specs[dep.name].each do |spec|
          if spec.non_library_specification?
            if s.test_specification? && spec.name == s.consumer(platform).app_host_name && spec.app_specification?
              # This needs to be handled separately, since we _don't_ want to treat this as a "normal" dependency
              next
            end
            raise Informative, "`#{s}` depends upon `#{spec}`, which is a `#{spec.spec_type}` spec."
          end

          dependent_specs.each do |config, set|
            next unless s.dependency_whitelisted_for_configuration?(dep, config)
            set << spec
          end
        end unless all_specs[dep.name].nil? # 解决 dep.name = xxx/binary 时,all_specs[dep.name]返回的是nil,导致调用 each 方法报错
      end
    end
  end

  Hash[dependent_specs.map { |k, v| [k, (v - specs).group_by(&:root)] }].freeze
end

#fetch_external_sources(podfile_state) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cocoapods-mtxx-bin/native/analyzer.rb', line 9

def fetch_external_sources(podfile_state)
  verify_no_pods_with_different_sources!
  deps = dependencies_to_fetch(podfile_state)
  pods = pods_to_fetch(podfile_state)
  return if deps.empty?
  UI.section 'Fetching external sources' do
    if installation_options.install_with_multi_threads
      thread_count = installation_options.multi_threads_count
      Parallel.each(deps.sort, in_threads: thread_count) do |dependency|
        fetch_external_source(dependency, !pods.include?(dependency.root_name))
      end
    else
      deps.sort.each do |dependency|
        fetch_external_source(dependency, !pods.include?(dependency.root_name))
      end
    end
  end
end

#old_dependencies_for_specsObject

解决 dep.name = xxx/binary 时,all_specs 返回nil,导致调用 each 方法报错



73
# File 'lib/cocoapods-mtxx-bin/native/analyzer.rb', line 73

alias old_dependencies_for_specs dependencies_for_specs

#old_fetch_external_sourcesObject



8
# File 'lib/cocoapods-mtxx-bin/native/analyzer.rb', line 8

alias old_fetch_external_sources fetch_external_sources

#old_update_repositoriesObject

> 1.5.3 版本 rewrite update_repositories



52
# File 'lib/cocoapods-mtxx-bin/native/analyzer.rb', line 52

alias old_update_repositories update_repositories

#update_repositoriesObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cocoapods-mtxx-bin/native/analyzer.rb', line 53

def update_repositories
  if installation_options.update_source_with_multi_threads
    # 并发更新私有源
    # 这里多线程会导致 pod update 额外输出 --verbose 的内容
    # 不知道为什么?
    thread_count = installation_options.multi_threads_count
    Parallel.each(sources.uniq(&:url), in_threads: thread_count) do |source|
      if source.updateable?
        sources_manager.update(source.name, true)
      else
        UI.message "Skipping `#{source.name}` update because the repository is not an updateable repository."
      end
    end
    @specs_updated = true
  else
    old_update_repositories
  end
end