Class: Pod::Installer::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-pod-linkage/patched_analyzer.rb

Instance Method Summary collapse

Instance Method Details

#generate_pod_targets(resolver_specs_by_target, target_inspections) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cocoapods-pod-linkage/patched_analyzer.rb', line 7

def generate_pod_targets(resolver_specs_by_target, target_inspections)
    targets = original_generate_pod_targets(resolver_specs_by_target, target_inspections)

    pod_targets = []
    targets.each { |target|
        explicit_linkage = target.target_definitions.map { |t| t.explicit_pod_linkage[target.pod_name] }.compact.first

        # We need to update the target only if we specified an explicit linkage
        if explicit_linkage
            override_target = ((explicit_linkage == :static && target.build_as_dynamic?) || (explicit_linkage == :dynamic && target.build_as_static?))

            # Create the correct Pod::BuildType because Pod::PodTarget doesn't expose it
            if target.build_as_framework?
                build_type = Pod::BuildType.new(:linkage => explicit_linkage, :packaging => :framework)
            else
                build_type = Pod::BuildType.new(:linkage => explicit_linkage, :packaging => :library)
            end

            # Pods are de-duplicated before this function, we need to merge them remove the scope suffix
            scope_suffix = target.scope_suffix
            if scope_suffix == 'static' || scope_suffix == 'dynamic'
                override_target = true
                scope_suffix = nil
            end

            if override_target
                # Create the new target
                target = Pod::PodTarget.new(
                    target.sandbox,
                    build_type,
                    target.user_build_configurations,
                    target.archs,
                    target.platform,
                    target.specs,
                    target.target_definitions,
                    target.file_accessors,
                    scope_suffix,
                    target.swift_version
                )

                # If we already have a target with the same name we just merge the target defitions
                # TODO: Check that all the other properties are really the same!
                existing_target = pod_targets.find { |t| t.label == target.label }
                if existing_target
                    Pod::UserInterface.message "- Merging #{target.pod_name} target definitions"

                    target = Pod::PodTarget.new(
                        existing_target.sandbox,
                        build_type,
                        existing_target.user_build_configurations,
                        existing_target.archs,
                        existing_target.platform,
                        existing_target.specs,
                        existing_target.target_definitions + target.target_definitions,
                        existing_target.file_accessors,
                        existing_target.scope_suffix,
                        existing_target.swift_version
                    )

                    pod_targets.delete existing_target
                else
                    Pod::UserInterface.message "- Updating #{target.pod_name}"
                end
            end
        end

        pod_targets.append target
    }

    all_specs = resolver_specs_by_target.values.flatten.map(&:spec).uniq.group_by(&:name)
    compute_pod_target_dependencies(pod_targets, all_specs)
end

#original_generate_pod_targetsObject



5
# File 'lib/cocoapods-pod-linkage/patched_analyzer.rb', line 5

alias_method :original_generate_pod_targets, :generate_pod_targets