Class: Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller

Inherits:
TargetInstaller
  • Object
show all
Defined in:
lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb

Overview

Creates the target for the Pods libraries in the Pods project and the relative support files.

Instance Attribute Summary collapse

Attributes inherited from TargetInstaller

#project, #sandbox, #target

Instance Method Summary collapse

Methods included from TargetInstallerHelper

create_info_plist_file_with_sandbox, update_changed_file

Constructor Details

#initialize(sandbox, project, target, umbrella_header_paths = nil) ⇒ PodTargetInstaller

Initialize a new instance

Parameters:

  • @see TargetInstaller#sandbox

  • @see TargetInstaller#project

  • @see TargetInstaller#target

  • (defaults to: nil)

    @see #umbrella_header_paths



20
21
22
23
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb', line 20

def initialize(sandbox, project, target, umbrella_header_paths = nil)
  super(sandbox, project, target)
  @umbrella_header_paths = umbrella_header_paths
end

Instance Attribute Details

#umbrella_header_pathsArray<Pathname> (readonly)

Returns Array of umbrella header paths in the headers directory.

Returns:

  • Array of umbrella header paths in the headers directory



11
12
13
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb', line 11

def umbrella_header_paths
  @umbrella_header_paths
end

Instance Method Details

#install!TargetInstallationResult

Creates the target in the Pods project and the relative support files.

Returns:

  • the result of the installation of this target.



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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb', line 29

def install!
  UI.message "- Installing target `#{target.name}` #{target.platform}" do
    create_support_files_dir
    test_file_accessors, file_accessors = target.file_accessors.partition { |fa| fa.spec.test_specification? }

    unless target.should_build?
      # For targets that should not be built (e.g. pre-built vendored frameworks etc), we add a placeholder
      # PBXAggregateTarget that will be used to wire up dependencies later.
      native_target = add_placeholder_target
      resource_bundle_targets = add_resources_bundle_targets(file_accessors).values.flatten
      create_xcconfig_file(native_target, resource_bundle_targets)
      return TargetInstallationResult.new(target, native_target, resource_bundle_targets)
    end

    native_target = add_target
    resource_bundle_targets = add_resources_bundle_targets(file_accessors).values.flatten

    test_native_targets = add_test_targets
    test_resource_bundle_targets = add_resources_bundle_targets(test_file_accessors)

    add_files_to_build_phases(native_target, test_native_targets)

    create_xcconfig_file(native_target, resource_bundle_targets)
    create_test_xcconfig_files(test_native_targets, test_resource_bundle_targets.values.flatten)

    if target.defines_module?
      create_module_map(native_target) do |generator|
        generator.headers.concat module_map_additional_headers
      end
      create_umbrella_header(native_target) do |generator|
        generator.imports += file_accessors.flat_map do |file_accessor|
          header_dir = if !target.requires_frameworks? && dir = file_accessor.spec_consumer.header_dir
                         Pathname.new(dir)
          end

          file_accessor.public_headers.map do |public_header|
            public_header = if header_mappings_dir
                              public_header.relative_path_from(header_mappings_dir)
                            else
                              public_header.basename
                            end
            if header_dir
              public_header = header_dir.join(public_header)
            end
            public_header
          end
        end
      end
    end

    if target.requires_frameworks?
      unless skip_info_plist?(native_target)
        create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
      end
      create_build_phase_to_symlink_header_folders(native_target)
    elsif target.uses_swift?
      add_swift_static_library_compatibility_header_phase(native_target)
    end

    unless skip_pch?(target.non_test_specs)
      path = target.prefix_header_path
      create_prefix_header(path, file_accessors, target.platform, [native_target])
    end
    unless skip_pch?(target.test_specs)
      target.supported_test_types.each do |test_type|
        path = target.prefix_header_path_for_test_type(test_type)
        create_prefix_header(path, test_file_accessors, target.platform, test_native_targets)
      end
    end
    create_dummy_source(native_target)
    clean_support_files_temp_dir
    TargetInstallationResult.new(target, native_target, resource_bundle_targets, test_native_targets,
                                 test_resource_bundle_targets)
  end
end