Class: Pod::Installer
- Inherits:
-
Object
- Object
- Pod::Installer
- Includes:
- Config::Mixin
- Defined in:
- lib/cocoapods/installer.rb,
lib/cocoapods/installer/analyzer.rb,
lib/cocoapods/installer/target_installer.rb,
lib/cocoapods/installer/pod_source_installer.rb,
lib/cocoapods/installer/user_project_integrator.rb,
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb,
lib/cocoapods/installer/file_references_installer.rb,
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
Overview
The Installer is responsible of taking a Podfile and transform it in the Pods libraries. It also integrates the user project so the Pods libraries can be used out of the box.
The Installer is capable of doing incremental updates to an existing Pod installation.
The Installer gets the information that it needs mainly from 3 files:
- Podfile: The specification written by the user that contains
information about targets and Pods.
- Podfile.lock: Contains information about the pods that were previously
installed and in concert with the Podfile provides information about
which specific version of a Pod should be installed. This file is
ignored in update mode.
- Manifest.lock: A file contained in the Pods folder that keeps track of
the pods installed in the local machine. This files is used once the
exact versions of the Pods has been computed to detect if that version
is already installed. This file is not intended to be kept under source
control and is a copy of the Podfile.lock.
The Installer is designed to work in environments where the Podfile folder is under source control and environments where it is not. The rest of the files, like the user project and the workspace are assumed to be under source control.
Defined Under Namespace
Classes: Analyzer, FileReferencesInstaller, PodSourceInstaller, TargetInstaller, UserProjectIntegrator
Installation results collapse
-
#analysis_result ⇒ Analyzer
readonly
The analyzer which provides the information about what needs to be installed.
-
#installed_specs ⇒ Array<Specification>
The specifications that where installed.
-
#libraries ⇒ Array<Library>
readonly
The libraries generated by the installation process.
-
#names_of_pods_to_install ⇒ Array<String>
readonly
The Pods that should be installed.
-
#pods_project ⇒ Pod::Project
readonly
The ‘Pods/Pods.xcodeproj` project.
Instance Attribute Summary collapse
-
#lockfile ⇒ Lockfile
readonly
The Lockfile that stores the information about the Pods previously installed on any machine.
-
#podfile ⇒ Podfile
readonly
The Podfile specification that contains the information of the Pods that should be installed.
-
#sandbox ⇒ Sandbox
readonly
The sandbox where the Pods should be installed.
-
#update_mode ⇒ Bool
Whether the installer is in update mode.
Hooks Data collapse
- #installer_rep ⇒ InstallerRepresentation
-
#libraries_using_spec(spec) ⇒ Array<Library>
Returns the libraries which use the given specification.
- #library_rep(library) ⇒ LibraryRepresentation
- #library_reps ⇒ Array<LibraryRepresentation>
- #pod_rep(pod) ⇒ PodRepresentation
- #pod_reps ⇒ Array<PodRepresentation>
Instance Method Summary collapse
- #download_dependencies ⇒ Object
- #generate_pods_project ⇒ Object
-
#initialize(sandbox, podfile, lockfile = nil) ⇒ Installer
constructor
A new instance of Installer.
-
#install! ⇒ void
Installs the Pods.
- #resolve_dependencies ⇒ Object
Methods included from Config::Mixin
Constructor Details
#initialize(sandbox, podfile, lockfile = nil) ⇒ Installer
Returns a new instance of Installer.
57 58 59 60 61 |
# File 'lib/cocoapods/installer.rb', line 57 def initialize(sandbox, podfile, lockfile = nil) @sandbox = sandbox @podfile = podfile @lockfile = lockfile end |
Instance Attribute Details
#analysis_result ⇒ Analyzer (readonly)
Returns the analyzer which provides the information about what needs to be installed.
127 128 129 |
# File 'lib/cocoapods/installer.rb', line 127 def analysis_result @analysis_result end |
#installed_specs ⇒ Array<Specification>
Returns The specifications that where installed.
144 145 146 |
# File 'lib/cocoapods/installer.rb', line 144 def installed_specs @installed_specs end |
#libraries ⇒ Array<Library> (readonly)
Returns The libraries generated by the installation process.
140 141 142 |
# File 'lib/cocoapods/installer.rb', line 140 def libraries @libraries end |
#lockfile ⇒ Lockfile (readonly)
Returns The Lockfile that stores the information about the Pods previously installed on any machine.
51 52 53 |
# File 'lib/cocoapods/installer.rb', line 51 def lockfile @lockfile end |
#names_of_pods_to_install ⇒ Array<String> (readonly)
Returns The Pods that should be installed.
135 136 137 |
# File 'lib/cocoapods/installer.rb', line 135 def names_of_pods_to_install @names_of_pods_to_install end |
#podfile ⇒ Podfile (readonly)
Returns The Podfile specification that contains the information of the Pods that should be installed.
46 47 48 |
# File 'lib/cocoapods/installer.rb', line 46 def podfile @podfile end |
#pods_project ⇒ Pod::Project (readonly)
Returns the ‘Pods/Pods.xcodeproj` project.
131 132 133 |
# File 'lib/cocoapods/installer.rb', line 131 def pods_project @pods_project end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
41 42 43 |
# File 'lib/cocoapods/installer.rb', line 41 def sandbox @sandbox end |
#update_mode ⇒ Bool
Returns Whether the installer is in update mode. In update mode the contents of the Lockfile are not taken into account for deciding what Pods to install.
67 68 69 |
# File 'lib/cocoapods/installer.rb', line 67 def update_mode @update_mode end |
Instance Method Details
#download_dependencies ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/cocoapods/installer.rb', line 98 def download_dependencies UI.section "Downloading dependencies" do create_file_accessors install_pod_sources run_pre_install_hooks clean_pod_sources end end |
#generate_pods_project ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/cocoapods/installer.rb', line 107 def generate_pods_project UI.section "Generating Pods project" do prepare_pods_project install_file_references install_targets run_post_install_hooks write_pod_project write_lockfiles end end |
#install! ⇒ void
This method returns an undefined value.
Installs the Pods.
The installation process of is mostly linear with 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).
83 84 85 86 87 88 |
# File 'lib/cocoapods/installer.rb', line 83 def install! resolve_dependencies download_dependencies generate_pods_project integrate_user_project if config.integrate_targets? end |
#installer_rep ⇒ InstallerRepresentation
503 504 505 |
# File 'lib/cocoapods/installer.rb', line 503 def installer_rep Hooks::InstallerRepresentation.new(self) end |
#libraries_using_spec(spec) ⇒ Array<Library>
Returns the libraries which use the given specification.
545 546 547 |
# File 'lib/cocoapods/installer.rb', line 545 def libraries_using_spec(spec) libraries.select { |lib| lib.specs.include?(spec) } end |
#library_rep(library) ⇒ LibraryRepresentation
522 523 524 |
# File 'lib/cocoapods/installer.rb', line 522 def library_rep(library) Hooks::LibraryRepresentation.new(sandbox, library) end |
#library_reps ⇒ Array<LibraryRepresentation>
528 529 530 |
# File 'lib/cocoapods/installer.rb', line 528 def library_reps @library_reps ||= libraries.map { |lib| library_rep(lib) } end |
#pod_rep(pod) ⇒ PodRepresentation
514 515 516 517 518 |
# File 'lib/cocoapods/installer.rb', line 514 def pod_rep(pod) all_file_accessors = libraries.map(&:file_accessors).flatten.compact file_accessors = all_file_accessors.select { |fa| fa.spec.root.name == pod } Hooks::PodRepresentation.new(pod, file_accessors) end |
#pod_reps ⇒ Array<PodRepresentation>
534 535 536 |
# File 'lib/cocoapods/installer.rb', line 534 def pod_reps root_specs.sort_by { |spec| spec.name }.map { |spec| pod_rep(spec.name) } end |
#resolve_dependencies ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/cocoapods/installer.rb', line 90 def resolve_dependencies UI.section "Analyzing dependencies" do analyze prepare_for_legacy_compatibility clean_sandbox end end |