Class: Pod::Installer::TargetInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/target_installer.rb

Overview

Controller class responsible of creating and configuring the static library target in Pods project. It also creates the support file needed by the target.

Direct Known Subclasses

AggregateTargetInstaller, PodTargetInstaller

Installation steps (collapse)

Private helpers. (collapse)

Instance Attribute Summary (collapse)

Installation steps (collapse)

Private helpers. (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TargetInstaller) initialize(sandbox, library)

Returns a new instance of TargetInstaller

Parameters:

  • project (Project)

    @see project

  • library (Library)

    @see library



22
23
24
25
# File 'lib/cocoapods/installer/target_installer.rb', line 22

def initialize(sandbox, library)
  @sandbox = sandbox
  @library = library
end

Instance Attribute Details

- (Library) library (readonly)

Returns The library whose target needs to be generated.

Returns:

  • (Library)

    The library whose target needs to be generated.



17
18
19
# File 'lib/cocoapods/installer/target_installer.rb', line 17

def library
  @library
end

- (Sandbox) sandbox (readonly)

Returns sandbox the sandbox where the support files should be generated.

Returns:

  • (Sandbox)

    sandbox the sandbox where the support files should be generated.



13
14
15
# File 'lib/cocoapods/installer/target_installer.rb', line 13

def sandbox
  @sandbox
end

- (PBXGroup) support_files_group (readonly, private)

Returns the group where the file references to the support files should be stored.

Returns:

  • (PBXGroup)

    the group where the file references to the support files should be stored.



115
116
117
# File 'lib/cocoapods/installer/target_installer.rb', line 115

def support_files_group
  @support_files_group
end

- (PBXNativeTarget) target (readonly, private)

Note:

Generated by the #add_target step.

Returns the target generated by the installation process.

Returns:

  • (PBXNativeTarget)

    the target generated by the installation process.



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

def target
  @target
end

Instance Method Details

- (PBXFileReference) add_file_to_support_group(path) (private)

Adds a reference to the given file in the support group of this target.

Parameters:

  • path (Pathname)

    The path of the file to which the reference should be added.

Returns:

  • (PBXFileReference)

    the file reference of the added file.



124
125
126
# File 'lib/cocoapods/installer/target_installer.rb', line 124

def add_file_to_support_group(path)
  support_files_group.new_file(path)
end

- (void) add_target (private)

Note:

The PODS_HEADERS_SEARCH_PATHS overrides the xcconfig.

This method returns an undefined value.

Adds the target for the library to the Pods project with the appropriate build configurations.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cocoapods/installer/target_installer.rb', line 40

def add_target
  name = library.label
  platform = library.platform.name
  deployment_target = library.platform.deployment_target.to_s
  @target = project.new_target(:static_library, name, platform, deployment_target)

  library.user_build_configurations.each do |bc_name, type|
    configuration = @target.add_build_configuration(bc_name, type)
  end


  settings = {}
  if library.archs
    settings['ARCHS'] = library.archs
  end

  @target.build_configurations.each do |configuration|
    configuration.build_settings.merge!(settings)
  end

  library.target = @target
end

- (void) create_dummy_source (private)

This method returns an undefined value.

Generates a dummy source file for each target so libraries that contain only categories build.



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

def create_dummy_source
  path = library.dummy_source_path
  UI.message "- Generating dummy source file at #{UI.path(path)}" do
    generator = Generator::DummySource.new(library.label)
    generator.save_as(path)
    file_reference = add_file_to_support_group(path)
    target.source_build_phase.add_file_reference(file_reference)
  end
end

- (void) create_suport_files_group (private)

This method returns an undefined value.

Creates the group that holds the references to the support files generated by this installer.



68
69
70
# File 'lib/cocoapods/installer/target_installer.rb', line 68

def create_suport_files_group
  @support_files_group = project.support_files_group.new_group(library.name)
end

- (Project) project (private)

Returns the Pods project of the sandbox.

Returns:

  • (Project)

    the Pods project of the sandbox.



102
103
104
# File 'lib/cocoapods/installer/target_installer.rb', line 102

def project
  sandbox.project
end

- (TargetDefinition) target_definition (private)

Returns the target definition of the library.

Returns:

  • (TargetDefinition)

    the target definition of the library.



108
109
110
# File 'lib/cocoapods/installer/target_installer.rb', line 108

def target_definition
  library.target_definition
end