Class: Pod::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-timeconsuming-details_for1.0.0.rb,
lib/cocoapods-timeconsuming-details_for0.35.0.rb,
lib/cocoapods-timeconsuming-details_for0.39.0.rb

Instance Method Summary collapse

Instance Method Details

#download_dependenciesObject



71
72
73
74
75
76
77
78
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 71

def download_dependencies
  UI.section 'Downloading dependencies' do
    timing("===> create_file_accessors", method(:create_file_accessors));
    timing("===> install_pod_sources", method(:install_pod_sources));
    timing("===> run_podfile_pre_install_hooks", method(:run_podfile_pre_install_hooks));
    timing("===> clean_pod_sources", method(:clean_pod_sources));
  end
end

#generate_pods_projectObject



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 80

def generate_pods_project
  UI.section 'Generating Pods project' do
    timing("===> prepare_pods_project", method(:prepare_pods_project));
    timing("===> install_file_references", method(:install_file_references));
    timing("===> install_libraries", method(:install_libraries));
    timing("===> set_target_dependencies", method(:set_target_dependencies));
    timing("===> run_podfile_post_install_hooks", method(:run_podfile_post_install_hooks));
    timing("===> write_pod_project", method(:write_pod_project));
    timing("===> share_development_pod_schemes", method(:share_development_pod_schemes));
    timing("===> write_lockfiles", method(:write_lockfiles));
  end
end

#install!void

This method returns an undefined value.

Installs the Pods.

The installation process is mostly linear with a few minor complications to keep in mind:

  • The stored podspecs need to be cleaned before the resolution step otherwise the sandbox might return an old podspec and not download the new one from an external source.

  • The resolver might trigger the download of Pods from external sources necessary to retrieve their podspec (unless it is instructed not to do it).



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 36

def install!

  start_time = Time.new  

  timing("=> prepare", method(:prepare));
  timing("=> resolve_dependencies", method(:resolve_dependencies));
  timing("=> download_dependencies", method(:download_dependencies));
  timing("=> verify_no_duplicate_framework_names", method(:verify_no_duplicate_framework_names));
  timing("=> verify_no_static_framework_transitive_dependencies", method(:verify_no_static_framework_transitive_dependencies));
  timing("=> verify_framework_usage", method(:verify_framework_usage));
  timing("=> generate_pods_project", method(:generate_pods_project));
  timing("=> integrate_user_project", method(:integrate_user_project)) if installation_options.integrate_targets?
  timing("=> perform_post_install_actions", method(:perform_post_install_actions));

  cost_time = (Time.new.to_f - start_time.to_f)*1000
  puts "\e[32m Total cost : #{cost_time.to_i.to_s} ms\e[0m"  
end

#install_librariesvoid

This method returns an undefined value.

Installs the aggregate targets of the Pods projects and generates their support files.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 141

def install_libraries
  UI.message '- Installing targets' do
    pod_targets.sort_by(&:name).each do |pod_target|
      target_installer = PodTargetInstaller.new(sandbox, pod_target)
      # target_installer.install!
      timing("install pod target #{pod_target.name}", target_installer.method(:install!));
    end

    aggregate_targets.sort_by(&:name).each do |target|
      target_installer = AggregateTargetInstaller.new(sandbox, target)
      # target_installer.install!
      timing("install aggregate target #{target.name}", target_installer.method(:install!));
    end

    # TODO: Move and add specs
    pod_targets.sort_by(&:name).each do |pod_target|
      pod_target.file_accessors.each do |file_accessor|
        file_accessor.spec_consumer.frameworks.each do |framework|
          if pod_target.should_build?
            pod_target.native_target.add_system_framework(framework)
          end
        end
      end
    end

  end
end

#install_source_of_pod(pod_name) ⇒ void

This method returns an undefined value.

Install the Pods. If the resolver indicated that a Pod should be installed and it exits, it is removed an then reinstalled. In any case if the Pod doesn’t exits it is installed.



130
131
132
133
134
135
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 130

def install_source_of_pod(pod_name)
  pod_installer = create_pod_installer(pod_name)
  # pod_installer.install!
  timing("=====> install #{pod_name}", pod_installer.method(:install!));
  @installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
end

#resolve_dependenciesObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 54

def resolve_dependencies
  analyzer = create_analyzer

  plugin_sources = run_source_provider_hooks
  analyzer.sources.insert(0, *plugin_sources)

  UI.section 'Updating local specs repositories' do
    timing("===> analyzer.update_repositories", analyzer.method(:update_repositories));
  end if repo_update?

  UI.section 'Analyzing dependencies' do
    timing("===> analyze(analyzer)", method(:analyze), analyzer);
    timing("===> validate_build_configurations", method(:validate_build_configurations));
    timing("===> clean_sandbox", method(:clean_sandbox));
  end
end

#timing(title, method, *argv) ⇒ Object

method(:method_name)



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cocoapods-timeconsuming-details_for1.0.0.rb', line 4

def timing (title, method, *argv) #method(:method_name)
    
  start_time = Time.new

  if argv and (argv.length != 0)
    method.call(*argv)
  else
    method.call
  end
    
  cost_time = (Time.new.to_f - start_time.to_f)*1000

  # return cost_time.to_i.to_s
  puts title + " cost : #{cost_time.to_i} ms";
end