Class: Pod::DyInstaller

Inherits:
Object
  • Object
show all
Includes:
Config::Mixin, InstallationOptions::Mixin
Defined in:
lib/pod/installer.rb,
lib/pod/installer/xcode.rb,
lib/pod/installer/analyzer.rb,
lib/pod/installer/podfile_validator.rb,
lib/pod/installer/pod_source_preparer.rb,
lib/pod/installer/analyzer/pod_variant.rb,
lib/pod/installer/analyzer/specs_state.rb,
lib/pod/installer/installation_options.rb,
lib/pod/installer/pod_source_installer.rb,
lib/pod/installer/xcode/target_validator.rb,
lib/pod/installer/user_project_integrator.rb,
lib/pod/installer/analyzer/analysis_result.rb,
lib/pod/installer/analyzer/pod_variant_set.rb,
lib/pod/installer/analyzer/sandbox_analyzer.rb,
lib/pod/installer/analyzer/target_inspector.rb,
lib/pod/installer/pre_install_hooks_context.rb,
lib/pod/installer/post_install_hooks_context.rb,
lib/pod/installer/xcode/pods_project_generator.rb,
lib/pod/installer/source_provider_hooks_context.rb,
lib/pod/installer/analyzer/podfile_dependency_cache.rb,
lib/pod/installer/analyzer/target_inspection_result.rb,
lib/pod/installer/analyzer/locking_dependency_analyzer.rb,
lib/pod/installer/user_project_integrator/target_integrator.rb,
lib/pod/installer/xcode/pods_project_generator/target_installer.rb,
lib/pod/installer/xcode/pods_project_generator/pod_target_installer.rb,
lib/pod/installer/xcode/pods_project_generator/pod_target_integrator.rb,
lib/pod/installer/xcode/pods_project_generator/file_references_installer.rb,
lib/pod/installer/xcode/pods_project_generator/aggregate_target_installer.rb,
lib/pod/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: Analyzer, InstallationOptions, PodSourceInstaller, PodSourcePreparer, PodfileValidator, PostInstallHooksContext, PreInstallHooksContext, SourceProviderHooksContext, UserProjectIntegrator, Xcode

Installation results collapse

Instance Attribute Summary collapse

Attributes included from InstallationOptions::Mixin

#installation_options

Installation results collapse

Hooks collapse

Instance Method Summary collapse

Methods included from InstallationOptions::Mixin

included

Constructor Details

#initialize(sandbox, podfile, lockfile = nil) ⇒ DyInstaller

Initialize a new instance

Parameters:

  • sandbox (Sandbox)

    @see sandbox

  • podfile (Podfile)

    @see podfile

  • lockfile (Lockfile) (defaults to: nil)

    @see lockfile



78
79
80
81
82
83
84
85
# File 'lib/pod/installer.rb', line 78

def initialize(sandbox, podfile, lockfile = nil)
  @sandbox  = sandbox
  @podfile  = podfile
  @lockfile = lockfile

  @use_default_plugins = true
  @has_dependencies = true
end

Instance Attribute Details

#aggregate_targetsArray<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.

Returns:

  • (Array<AggregateTarget>)

    The model representations of an aggregation of pod targets generated for a target definition in the Podfile as result of the analyzer.



243
244
245
# File 'lib/pod/installer.rb', line 243

def aggregate_targets
  @aggregate_targets
end

#analysis_resultAnalyzer (readonly)

Returns the analyzer which provides the information about what needs to be installed.

Returns:

  • (Analyzer)

    the analyzer which provides the information about what needs to be installed.



229
230
231
# File 'lib/pod/installer.rb', line 229

def analysis_result
  @analysis_result
end

#has_dependenciesBoolean Also known as: has_dependencies?

Returns Whether it has dependencies. Defaults to true.

Returns:

  • (Boolean)

    Whether it has dependencies. Defaults to true.



96
97
98
# File 'lib/pod/installer.rb', line 96

def has_dependencies
  @has_dependencies
end

#installed_specsArray<Specification>

Returns The specifications that where installed.

Returns:

  • (Array<Specification>)

    The specifications that where installed.



256
257
258
# File 'lib/pod/installer.rb', line 256

def installed_specs
  @installed_specs
end

#lockfileLockfile (readonly)

Returns The Lockfile that stores the information about the Pods previously installed on any machine.

Returns:

  • (Lockfile)

    The Lockfile that stores the information about the Pods previously installed on any machine.



70
71
72
# File 'lib/pod/installer.rb', line 70

def lockfile
  @lockfile
end

#names_of_pods_to_installArray<String> (readonly)

Returns The Pods that should be installed.

Returns:

  • (Array<String>)

    The Pods that should be installed.



237
238
239
# File 'lib/pod/installer.rb', line 237

def names_of_pods_to_install
  @names_of_pods_to_install
end

#podfilePodfile (readonly)

Returns The Podfile specification that contains the information of the Pods that should be installed.

Returns:

  • (Podfile)

    The Podfile specification that contains the information of the Pods that should be installed.



65
66
67
# File 'lib/pod/installer.rb', line 65

def podfile
  @podfile
end

#pods_projectPod::Project (readonly)

Returns the ‘Pods/Pods.xcodeproj` project.

Returns:

  • (Pod::Project)

    the ‘Pods/Pods.xcodeproj` project.



233
234
235
# File 'lib/pod/installer.rb', line 233

def pods_project
  @pods_project
end

#repo_updateBoolean Also known as: repo_update?

Returns Whether the spec repos should be updated.

Returns:

  • (Boolean)

    Whether the spec repos should be updated.



101
102
103
# File 'lib/pod/installer.rb', line 101

def repo_update
  @repo_update
end

#sandboxSandbox (readonly)

Returns The sandbox where the Pods should be installed.

Returns:

  • (Sandbox)

    The sandbox where the Pods should be installed.



60
61
62
# File 'lib/pod/installer.rb', line 60

def sandbox
  @sandbox
end

#updateHash, ...

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.

Returns:

  • (Hash, Boolean, nil)

    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.



92
93
94
# File 'lib/pod/installer.rb', line 92

def update
  @update
end

#use_default_pluginsBoolean Also known as: use_default_plugins?

Returns Whether default plugins should be used during installation. Defaults to true.

Returns:

  • (Boolean)

    Whether default plugins should be used during installation. Defaults to true.



107
108
109
# File 'lib/pod/installer.rb', line 107

def use_default_plugins
  @use_default_plugins
end

Instance Method Details

#development_pod_targetsArray<PodTarget>

Returns The targets of the development pods generated by the installation process. This can be used as a convenience method for external scripts.

Returns:

  • (Array<PodTarget>)

    The targets of the development pods generated by the installation process. This can be used as a convenience method for external scripts.



688
689
690
691
692
# File 'lib/pod/installer.rb', line 688

def development_pod_targets
  pod_targets.select do |pod_target|
    sandbox.local?(pod_target.pod_name)
  end
end

#download_dependenciesObject



188
189
190
191
192
193
194
195
# File 'lib/pod/installer.rb', line 188

def download_dependencies
  UI.section 'Downloading dependencies' do
    create_file_accessors
    install_pod_sources
    run_podfile_pre_install_hooks
    clean_pod_sources
  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).



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/pod/installer.rb', line 124

def install!
  before_prepare = Time.now
  prepare
  before_resolve = Time.now
  resolve_dependencies
  before_download = Time.now
  download_dependencies
  before_validate_targets = Time.now
  validate_targets
  before_generate = Time.now
  generate_pods_project
  before_integreate = Time.now
  if installation_options.integrate_targets?
    integrate_user_project
  else
    UI.section 'Skipping User Project Integration'
  end
  before_post = Time.now
  perform_post_install_actions
  after_post = Time.now
  puts('Time result:')
  puts("  【total: #{after_post - before_prepare}】")
  puts("  【prepare: #{before_resolve - before_prepare}】")
  puts("  【resolve_dependencies: #{before_download - before_resolve}】")
  puts("  【download_dependencies: #{before_validate_targets - before_download}】")
  puts("  【validate_targets: #{before_generate - before_validate_targets}】")
  puts("  【generate_pods_project: #{before_integreate - before_generate}】")
  puts("  【integrate_user_project: #{before_post - before_integreate}】")
  puts("  【perform_post_install_actions: #{after_post - before_post}】")
end

#pod_targetsArray<PodTarget>

Returns The model representations of pod targets generated as result of the analyzer.

Returns:

  • (Array<PodTarget>)

    The model representations of pod targets generated as result of the analyzer.



248
249
250
251
252
# File 'lib/pod/installer.rb', line 248

def pod_targets
  aggregate_target_pod_targets = aggregate_targets.flat_map(&:pod_targets)
  test_dependent_targets = aggregate_target_pod_targets.flat_map(&:test_dependent_targets)
  (aggregate_target_pod_targets + test_dependent_targets).uniq
end

#prepareObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/pod/installer.rb', line 155

def prepare
  # Raise if pwd is inside Pods
  if Dir.pwd.start_with?(sandbox.root.to_path)
    message = 'Command should be run from a directory outside Pods directory.'
    message << "\n\n\tCurrent directory is #{UI.path(Pathname.pwd)}\n"
    raise Informative, message
  end
  UI.message 'Preparing' do
    deintegrate_if_different_major_version
    sandbox.prepare
    ensure_plugins_are_installed!
    run_plugins_pre_install_hooks
  end
end

#resolve_dependenciesAnalyzer

Returns The analyzer used to resolve dependencies.

Returns:

  • (Analyzer)

    The analyzer used to resolve dependencies



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/pod/installer.rb', line 172

def resolve_dependencies
  plugin_sources = run_source_provider_hooks
  analyzer = create_analyzer(plugin_sources)

  UI.section 'Updating local specs repositories' do
    analyzer.update_repositories
  end if repo_update?

  UI.section 'Analyzing dependencies' do
    analyze(analyzer)
    validate_build_configurations
    clean_sandbox
  end
  analyzer
end