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/migrator.rb,
lib/cocoapods/installer/target_installer.rb,
lib/cocoapods/installer/podfile_validator.rb,
lib/cocoapods/installer/pod_source_preparer.rb,
lib/cocoapods/installer/analyzer/specs_state.rb,
lib/cocoapods/installer/pod_source_installer.rb,
lib/cocoapods/installer/user_project_integrator.rb,
lib/cocoapods/installer/analyzer/analysis_result.rb,
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb,
lib/cocoapods/installer/analyzer/target_inspector.rb,
lib/cocoapods/installer/file_references_installer.rb,
lib/cocoapods/installer/pre_install_hooks_context.rb,
lib/cocoapods/installer/post_install_hooks_context.rb,
lib/cocoapods/installer/analyzer/target_inspection_result.rb,
lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb,
lib/cocoapods/installer/target_installer/pod_target_installer.rb,
lib/cocoapods/installer/user_project_integrator/target_integrator.rb,
lib/cocoapods/installer/target_installer/aggregate_target_installer.rb,
lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_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: AggregateTargetInstaller, Analyzer, FileReferencesInstaller, Migrator, PodSourceInstaller, PodSourcePreparer, PodTargetInstaller, PodfileValidator, PostInstallHooksContext, PreInstallHooksContext, TargetInstaller, UserProjectIntegrator
Installation results collapse
-
#aggregate_targets ⇒ Array<AggregateTarget>
readonly
The model representations of an aggregation of pod targets generated for a target definition in the Podfile as result of the analyzer.
-
#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.
-
#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 ⇒ Hash, ...
Pods that have been requested to be updated or true if all Pods should be updated.
-
#use_default_plugins ⇒ Boolean
(also: #use_default_plugins?)
Whether default plugins should be used during installation.
Installation results collapse
-
#pod_targets ⇒ Array<PodTarget>
The model representations of pod targets generated as result of the analyzer.
Hooks collapse
-
#development_pod_targets ⇒ Array<Library>
The targets of the development pods generated by the installation process.
Instance Method Summary collapse
- #download_dependencies ⇒ Object
- #generate_pods_project ⇒ Object
-
#initialize(sandbox, podfile, lockfile = nil) ⇒ Installer
constructor
Initialize a new instance.
-
#install! ⇒ void
Installs the Pods.
- #prepare ⇒ Object
- #resolve_dependencies ⇒ Object
Methods included from Config::Mixin
Constructor Details
#initialize(sandbox, podfile, lockfile = nil) ⇒ Installer
Initialize a new instance
67 68 69 70 71 72 73 |
# File 'lib/cocoapods/installer.rb', line 67 def initialize(sandbox, podfile, lockfile = nil) @sandbox = sandbox @podfile = podfile @lockfile = lockfile @use_default_plugins = true end |
Instance Attribute Details
#aggregate_targets ⇒ Array<AggregateTarget> (readonly)
Returns The model representations of an aggregation of pod targets generated for a target definition in the Podfile as result of the analyzer.
185 186 187 |
# File 'lib/cocoapods/installer.rb', line 185 def aggregate_targets @aggregate_targets end |
#analysis_result ⇒ Analyzer (readonly)
Returns the analyzer which provides the information about what needs to be installed.
171 172 173 |
# File 'lib/cocoapods/installer.rb', line 171 def analysis_result @analysis_result end |
#installed_specs ⇒ Array<Specification>
Returns The specifications that where installed.
196 197 198 |
# File 'lib/cocoapods/installer.rb', line 196 def installed_specs @installed_specs end |
#lockfile ⇒ Lockfile (readonly)
Returns The Lockfile that stores the information about the Pods previously installed on any machine.
59 60 61 |
# File 'lib/cocoapods/installer.rb', line 59 def lockfile @lockfile end |
#names_of_pods_to_install ⇒ Array<String> (readonly)
Returns The Pods that should be installed.
179 180 181 |
# File 'lib/cocoapods/installer.rb', line 179 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.
54 55 56 |
# File 'lib/cocoapods/installer.rb', line 54 def podfile @podfile end |
#pods_project ⇒ Pod::Project (readonly)
Returns the ‘Pods/Pods.xcodeproj` project.
175 176 177 |
# File 'lib/cocoapods/installer.rb', line 175 def pods_project @pods_project end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
49 50 51 |
# File 'lib/cocoapods/installer.rb', line 49 def sandbox @sandbox end |
#update ⇒ Hash, ...
Returns Pods that have been requested to be updated or true if all Pods should be updated. If all Pods should been updated the contents of the Lockfile are not taken into account for deciding what Pods to install.
80 81 82 |
# File 'lib/cocoapods/installer.rb', line 80 def update @update end |
#use_default_plugins ⇒ Boolean Also known as: use_default_plugins?
Returns Whether default plugins should be used during installation. Defaults to true.
85 86 87 |
# File 'lib/cocoapods/installer.rb', line 85 def use_default_plugins @use_default_plugins end |
Instance Method Details
#development_pod_targets ⇒ Array<Library>
Returns The targets of the development pods generated by the installation process.
778 779 780 781 782 |
# File 'lib/cocoapods/installer.rb', line 778 def development_pod_targets pod_targets.select do |pod_target| sandbox.development_pods.keys.include?(pod_target.pod_name) end end |
#download_dependencies ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/cocoapods/installer.rb', line 140 def download_dependencies UI.section 'Downloading dependencies' do create_file_accessors install_pod_sources run_podfile_pre_install_hooks clean_pod_sources end end |
#generate_pods_project ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/cocoapods/installer.rb', line 149 def generate_pods_project UI.section 'Generating Pods project' do prepare_pods_project install_file_references install_libraries set_target_dependencies run_podfile_post_install_hooks write_pod_project share_development_pod_schemes 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).
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/cocoapods/installer.rb', line 102 def install! prepare resolve_dependencies download_dependencies determine_dependency_product_types verify_no_duplicate_framework_names verify_no_static_framework_transitive_dependencies verify_framework_usage generate_pods_project integrate_user_project if config.integrate_targets? perform_post_install_actions end |
#pod_targets ⇒ Array<PodTarget>
Returns The model representations of pod targets generated as result of the analyzer.
190 191 192 |
# File 'lib/cocoapods/installer.rb', line 190 def pod_targets aggregate_targets.map(&:pod_targets).flatten.uniq end |
#prepare ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/cocoapods/installer.rb', line 115 def prepare UI. 'Preparing' do FileUtils.chmod_R('+w', sandbox.root) sandbox.prepare ensure_plugins_are_installed! Migrator.migrate(sandbox) run_plugins_pre_install_hooks end end |
#resolve_dependencies ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/cocoapods/installer.rb', line 125 def resolve_dependencies analyzer = create_analyzer UI.section 'Updating local specs repositories' do analyzer.update_repositories end unless config.skip_repo_update? UI.section 'Analyzing dependencies' do analyze(analyzer) validate_build_configurations prepare_for_legacy_compatibility clean_sandbox end end |