Class: Pod::AggregateTarget

Inherits:
Target
  • Object
show all
Defined in:
lib/cocoapods/target/aggregate_target.rb

Overview

Stores the information relative to the target used to cluster the targets of the single Pods. The client targets will then depend on this one.

Instance Attribute Summary collapse

Attributes inherited from Target

#archs, #host_requires_frameworks, #native_target, #sandbox, #user_build_configurations

Support files collapse

Instance Method Summary collapse

Methods inherited from Target

#bridge_support_path, #dummy_source_path, #framework_name, #info_plist_path, #inspect, #module_map_path, #name, #prefix_header_path, #product_basename, #product_name, #product_type, #requires_frameworks?, #static_library_name, #support_files_dir, #umbrella_header_path, #xcconfig_path, #xcconfig_prefix, #xcconfig_private_path

Constructor Details

#initialize(target_definition, sandbox) ⇒ AggregateTarget

Initialize a new instance

Parameters:

  • target_definition (TargetDefinition)

    @see target_definition

  • sandbox (Sandbox)

    @see sandbox



15
16
17
18
19
20
21
22
# File 'lib/cocoapods/target/aggregate_target.rb', line 15

def initialize(target_definition, sandbox)
  super()
  @target_definition = target_definition
  @sandbox = sandbox
  @pod_targets = []
  @file_accessors = []
  @xcconfigs = {}
end

Instance Attribute Details

#client_rootPathname

Returns the folder where the client is stored used for computing the relative paths. If integrating it should be the folder where the user project is stored, otherwise it should be the installation root.

Returns:

  • (Pathname)

    the folder where the client is stored used for computing the relative paths. If integrating it should be the folder where the user project is stored, otherwise it should be the installation root.



55
56
57
# File 'lib/cocoapods/target/aggregate_target.rb', line 55

def client_root
  @client_root
end

#pod_targetsArray<PodTarget>

Returns The dependencies for this target.

Returns:

  • (Array<PodTarget>)

    The dependencies for this target.



104
105
106
# File 'lib/cocoapods/target/aggregate_target.rb', line 104

def pod_targets
  @pod_targets
end

#target_definitionTargetDefinition (readonly)

Returns the target definition of the Podfile that generated this target.

Returns:

  • (TargetDefinition)

    the target definition of the Podfile that generated this target.



8
9
10
# File 'lib/cocoapods/target/aggregate_target.rb', line 8

def target_definition
  @target_definition
end

#user_project_pathPathname

Note:

The project instance is not stored to prevent editing different instances.

Returns the path of the user project that this target will integrate as identified by the analyzer.

Returns:

  • (Pathname)

    the path of the user project that this target will integrate as identified by the analyzer.



63
64
65
# File 'lib/cocoapods/target/aggregate_target.rb', line 63

def user_project_path
  @user_project_path
end

#user_target_uuidsArray<String>

Note:

The target instances are not stored to prevent editing different instances.

Returns the list of the UUIDs of the user targets that will be integrated by this target as identified by the analyzer.

Returns:

  • (Array<String>)

    the list of the UUIDs of the user targets that will be integrated by this target as identified by the analyzer.



71
72
73
# File 'lib/cocoapods/target/aggregate_target.rb', line 71

def user_target_uuids
  @user_target_uuids
end

#xcconfigsHash<String, Xcodeproj::Config> (readonly)

Note:

The configurations are generated by the TargetInstaller and used by UserProjectIntegrator to check for any overridden values.

Returns Map from configuration name to configuration file for the target.

Returns:

  • (Hash<String, Xcodeproj::Config>)

    Map from configuration name to configuration file for the target



100
101
102
# File 'lib/cocoapods/target/aggregate_target.rb', line 100

def xcconfigs
  @xcconfigs
end

Instance Method Details

#acknowledgements_basepathPathname

Note:

The acknowledgements generators add the extension according to the file type.

Returns The absolute path of acknowledgements file.

Returns:

  • (Pathname)

    The absolute path of acknowledgements file.



157
158
159
# File 'lib/cocoapods/target/aggregate_target.rb', line 157

def acknowledgements_basepath
  support_files_dir + "#{label}-acknowledgements"
end

#copy_resources_script_pathPathname

Returns The absolute path of the copy resources script.

Returns:

  • (Pathname)

    The absolute path of the copy resources script.



163
164
165
# File 'lib/cocoapods/target/aggregate_target.rb', line 163

def copy_resources_script_path
  support_files_dir + "#{label}-resources.sh"
end

#copy_resources_script_relative_pathString

Returns The path of the copy resources script relative to the root of the user project.

Returns:

  • (String)

    The path of the copy resources script relative to the root of the user project.



191
192
193
# File 'lib/cocoapods/target/aggregate_target.rb', line 191

def copy_resources_script_relative_path
  "${SRCROOT}/#{relative_to_srcroot(copy_resources_script_path)}"
end

#embed_frameworks_script_pathPathname

Returns The absolute path of the embed frameworks script.

Returns:

  • (Pathname)

    The absolute path of the embed frameworks script.



169
170
171
# File 'lib/cocoapods/target/aggregate_target.rb', line 169

def embed_frameworks_script_path
  support_files_dir + "#{label}-frameworks.sh"
end

#embed_frameworks_script_relative_pathString

Returns The path of the embed frameworks relative to the root of the user project.

Returns:

  • (String)

    The path of the embed frameworks relative to the root of the user project.



198
199
200
# File 'lib/cocoapods/target/aggregate_target.rb', line 198

def embed_frameworks_script_relative_path
  "${SRCROOT}/#{relative_to_srcroot(embed_frameworks_script_path)}"
end

#labelString

Returns the label for the target.

Returns:

  • (String)

    the label for the target.



26
27
28
# File 'lib/cocoapods/target/aggregate_target.rb', line 26

def label
  target_definition.label.to_s
end

#platformPlatform

Returns the platform for this target.

Returns:

  • (Platform)

    the platform for this target.



40
41
42
# File 'lib/cocoapods/target/aggregate_target.rb', line 40

def platform
  @platform ||= target_definition.platform
end

#pod_targets_for_build_configuration(build_configuration) ⇒ Array<PodTarget>

Returns the pod targets for the given build configuration.

Parameters:

  • build_configuration (String)

    The build configuration for which the the pod targets should be returned.

Returns:

  • (Array<PodTarget>)

    the pod targets for the given build configuration.



112
113
114
115
116
# File 'lib/cocoapods/target/aggregate_target.rb', line 112

def pod_targets_for_build_configuration(build_configuration)
  pod_targets.select do |pod_target|
    pod_target.include_in_build_config?(target_definition, build_configuration)
  end
end

#podfilePodfile

Returns The podfile which declares the dependency.

Returns:

  • (Podfile)

    The podfile which declares the dependency



46
47
48
# File 'lib/cocoapods/target/aggregate_target.rb', line 46

def podfile
  target_definition.podfile
end

#product_module_nameString

Returns the name to use for the source code module constructed for this target, and which will be used to import the module in implementation source files.

Returns:

  • (String)

    the name to use for the source code module constructed for this target, and which will be used to import the module in implementation source files.



34
35
36
# File 'lib/cocoapods/target/aggregate_target.rb', line 34

def product_module_name
  c99ext_identifier(label)
end

#relative_pods_rootString

Returns The xcconfig path of the root from the ‘$(SRCROOT)` variable of the user’s project.

Returns:

  • (String)

    The xcconfig path of the root from the ‘$(SRCROOT)` variable of the user’s project.



176
177
178
# File 'lib/cocoapods/target/aggregate_target.rb', line 176

def relative_pods_root
  "${SRCROOT}/#{sandbox.root.relative_path_from(client_root)}"
end

#scoped_configuration_build_dirString

Returns The scoped configuration build dir, relevant if the target is integrated as framework.

Returns:

  • (String)

    The scoped configuration build dir, relevant if the target is integrated as framework.



205
206
207
# File 'lib/cocoapods/target/aggregate_target.rb', line 205

def scoped_configuration_build_dir
  "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/#{target_definition.label}"
end

#spec_consumersArray<Specification::Consumer>

Returns The consumers of the Pod.

Returns:

  • (Array<Specification::Consumer>)

    The consumers of the Pod.



138
139
140
# File 'lib/cocoapods/target/aggregate_target.rb', line 138

def spec_consumers
  specs.map { |spec| spec.consumer(platform) }
end

#specsArray<Specification>

Returns The specifications used by this aggregate target.

Returns:

  • (Array<Specification>)

    The specifications used by this aggregate target.



120
121
122
# File 'lib/cocoapods/target/aggregate_target.rb', line 120

def specs
  pod_targets.map(&:specs).flatten
end

#specs_by_build_configurationHash{Symbol => Array<Specification>}

Returns The pod targets for each build configuration.

Returns:

  • (Hash{Symbol => Array<Specification>})

    The pod targets for each build configuration.



127
128
129
130
131
132
133
134
# File 'lib/cocoapods/target/aggregate_target.rb', line 127

def specs_by_build_configuration
  result = {}
  user_build_configurations.keys.each do |build_configuration|
    result[build_configuration] = pod_targets_for_build_configuration(build_configuration).
      flat_map(&:specs)
  end
  result
end

#user_targets(project = nil) ⇒ Array<PBXNativeTarget>

List all user targets that will be integrated by this #target.

Parameters:

  • project (Xcodeproj::Project) (defaults to: nil)

    The project to search for the user targets

Returns:

  • (Array<PBXNativeTarget>)


80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cocoapods/target/aggregate_target.rb', line 80

def user_targets(project = nil)
  return [] unless user_project_path
  project ||= Xcodeproj::Project.open(user_project_path)
  user_target_uuids.map do |uuid|
    native_target = project.objects_by_uuid[uuid]
    unless native_target
      raise Informative, '[Bug] Unable to find the target with ' \
        "the `#{uuid}` UUID for the `#{self}` integration library"
    end
    native_target
  end
end

#uses_swift?Boolean

Returns Whether the target uses Swift code.

Returns:

  • (Boolean)

    Whether the target uses Swift code



144
145
146
# File 'lib/cocoapods/target/aggregate_target.rb', line 144

def uses_swift?
  pod_targets.any?(&:uses_swift?)
end

#xcconfig_relative_path(config_name) ⇒ String

Returns The path of the xcconfig file relative to the root of the user project.

Parameters:

  • config_name (String)

    The build configuration name to get the xcconfig for

Returns:

  • (String)

    The path of the xcconfig file relative to the root of the user project.



184
185
186
# File 'lib/cocoapods/target/aggregate_target.rb', line 184

def xcconfig_relative_path(config_name)
  relative_to_srcroot(xcconfig_path(config_name)).to_s
end