Class: Pod::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/pod-binary/integration/validation.rb,
lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb,
lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb,
lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb,
lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb,
lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb,
lib/cocoapods-binary-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb

Direct Known Subclasses

PrebuildInstaller

Defined Under Namespace

Classes: Analyzer, PrebuiltSourceInstaller

Instance Method Summary collapse

Instance Method Details

#alter_specs_for_prebuilt_podsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb', line 3

def alter_specs_for_prebuilt_pods
  cache = []

  @original_specs = analysis_result.specifications
    .map { |spec| [spec.name, Pod::Specification.from_file(spec.defined_in_file)] }
    .to_h

  analysis_result.specifications
    .select { |spec| should_integrate_prebuilt_pod?(spec.root.name) }
    .group_by(&:root)
    .each do |_, specs|
      first_subspec_or_self = specs.find(&:subspec?) || specs[0]
      specs.each do |spec|
        alterations = {
          :source_files => true,
          :resources => true,
          :license => true,
          :vendored_framework => spec == first_subspec_or_self
        }
        alter_spec(spec, alterations, cache)
      end
    end
end

#create_pod_installer(name) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb', line 7

def create_pod_installer(name)
  if should_integrate_prebuilt_pod?(name)
    create_prebuilt_source_installer(name)
  else
    create_normal_source_installer(name)
  end
end

#original_create_pod_installerObject

Override the download step to skip download and prepare file in target folder



6
# File 'lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb', line 6

alias original_create_pod_installer create_pod_installer

#prebuilt_pod_namesObject

Returns the names of pod targets detected as prebuilt, including those declared in Podfile and their dependencies



5
6
7
# File 'lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb', line 5

def prebuilt_pod_names
  prebuilt_pod_targets.map(&:name).to_set
end

#prebuilt_pod_targetsObject

Returns the pod targets detected as prebuilt, including those declared in Podfile and their dependencies



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb', line 11

def prebuilt_pod_targets
  @prebuilt_pod_targets ||= begin
    explicit_prebuilt_pod_names = aggregate_targets
      .flat_map { |target| target.target_definition.explicit_prebuilt_pod_names }
      .uniq

    targets = pod_targets.select { |target| explicit_prebuilt_pod_names.include?(target.pod_name) }
    dependencies = targets.flat_map(&:recursive_dependent_targets) # Treat dependencies as prebuilt pods
    all = (targets + dependencies).uniq
    all = all.reject { |target| sandbox.local?(target.pod_name) } unless PodPrebuild.config.dev_pods_enabled?
    all
  end
end

#validate_every_pod_only_have_one_formObject

Raises:

  • (Informative)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cocoapods-binary-cache/pod-binary/integration/validation.rb', line 3

def validate_every_pod_only_have_one_form
  multi_targets_pods = pod_targets
    .group_by(&:pod_name)
    .select do |_, targets|
      is_multi_targets = targets.map { |t| t.platform.name }.uniq.count > 1
      is_multi_forms = targets.map { |t| prebuilt_pod_targets.include?(t) }.uniq.count > 1
      is_multi_targets && is_multi_forms
    end
  return if multi_targets_pods.empty?

  warnings = "One pod can only be prebuilt or not prebuilt. These pod have different forms in multiple targets:\n"
  warnings += multi_targets_pods
    .map { |name, targets| "         #{name}: #{targets.map { |t| t.platform.name }}" }
    .join("\n")
  raise Informative, warnings
end