class Pod::AggregateTarget

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.

Constants

EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES

Product types where the product's frameworks must be embedded in a host target

Attributes

client_root[R]

@return [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.
pod_targets[RW]

@return [Array<PodTarget>] The dependencies for this target.

search_paths_aggregate_targets[R]

@return [Array<AggregateTarget>] The aggregate targets whose pods this

target must be able to import, but will not directly link against.
target_definition[R]

@return [TargetDefinition] the target definition of the Podfile that

generated this target.
user_project[R]

@return [Xcodeproj::Project] the user project that this target will

integrate as identified by the analyzer.
user_target_uuids[R]

@return [Array<String>] the list of the UUIDs of the user targets that

will be integrated by this target as identified by the analyzer.

@note The target instances are not stored to prevent editing different

instances.
xcconfigs[R]

@return [Hash<String, Xcodeproj::Config>] Map from configuration name to

configuration file for the target

@note The configurations are generated by the {TargetInstaller} and

used by {UserProjectIntegrator} to check for any overridden
values.

Public Class Methods

new(sandbox, host_requires_frameworks, user_build_configurations, archs, platform, target_definition, client_root, user_project, user_target_uuids, pod_targets_for_build_configuration) click to toggle source

Initialize a new instance

@param [Sandbox] sandbox @see Target#sandbox @param [Boolean] host_requires_frameworks @see Target#host_requires_frameworks @param [Hash{String=>Symbol}] user_build_configurations @see Target#user_build_configurations @param [Array<String>] archs @see Target#archs @param [Platform] platform @see #Target#platform @param [TargetDefinition] target_definition @see target_definition @param [Pathname] client_root @see client_root @param [Xcodeproj::Project] user_project @see user_project @param [Array<String>] user_target_uuids @see user_target_uuids @param [Array<PodTarget>] pod_targets_for_build_configuration @see pod_targets_for_build_configuration

Calls superclass method Pod::Target::new
# File lib/cocoapods/target/aggregate_target.rb, line 66
def initialize(sandbox, host_requires_frameworks, user_build_configurations, archs, platform, target_definition,
               client_root, user_project, user_target_uuids, pod_targets_for_build_configuration)
  super(sandbox, host_requires_frameworks, user_build_configurations, archs, platform)
  raise "Can't initialize an AggregateTarget without a TargetDefinition!" if target_definition.nil?
  raise "Can't initialize an AggregateTarget with an abstract TargetDefinition!" if target_definition.abstract?
  @target_definition = target_definition
  @client_root = client_root
  @user_project = user_project
  @user_target_uuids = user_target_uuids
  @pod_targets_for_build_configuration = pod_targets_for_build_configuration
  @pod_targets = pod_targets_for_build_configuration.values.flatten.uniq
  @search_paths_aggregate_targets = []
  @xcconfigs = {}
end

Public Instance Methods

acknowledgements_basepath() click to toggle source

@return [Pathname] The absolute path of acknowledgements file.

@note The acknowledgements generators add the extension according to

the file type.
# File lib/cocoapods/target/aggregate_target.rb, line 244
def acknowledgements_basepath
  support_files_dir + "#{label}-acknowledgements"
end
bridge_support_file() click to toggle source

@return [Pathname] the path of the bridge support file relative to the

sandbox or `nil` if bridge support is disabled.
# File lib/cocoapods/target/aggregate_target.rb, line 231
def bridge_support_file
  bridge_support_path.relative_path_from(sandbox.root) if podfile.generate_bridge_support?
end
build_settings(configuration_name = nil) click to toggle source
# File lib/cocoapods/target/aggregate_target.rb, line 81
def build_settings(configuration_name = nil)
  if configuration_name
    @build_settings[configuration_name] ||
      raise(ArgumentError, "#{self} does not contain a build setting for the #{configuration_name.inspect} configuration, only #{@build_settings.keys.inspect}")
  else
    @build_settings.each_value.first ||
      raise(ArgumentError, "#{self} does not contain any build settings")
  end
end
check_manifest_lock_script_output_file_path() click to toggle source

@return [String] The output file path fo the check manifest lock script.

# File lib/cocoapods/target/aggregate_target.rb, line 262
def check_manifest_lock_script_output_file_path
  "$(DERIVED_FILE_DIR)/#{label}-checkManifestLockResult.txt"
end
copy_resources_script_path() click to toggle source

@return [Pathname] The absolute path of the copy resources script.

# File lib/cocoapods/target/aggregate_target.rb, line 250
def copy_resources_script_path
  support_files_dir + "#{label}-resources.sh"
end
copy_resources_script_relative_path() click to toggle source

@return [String] The path of the copy resources script relative to the

root of the Pods project.
# File lib/cocoapods/target/aggregate_target.rb, line 300
def copy_resources_script_relative_path
  "${PODS_ROOT}/#{relative_to_pods_root(copy_resources_script_path)}"
end
embed_frameworks_script_path() click to toggle source

@return [Pathname] The absolute path of the embed frameworks script.

# File lib/cocoapods/target/aggregate_target.rb, line 256
def embed_frameworks_script_path
  support_files_dir + "#{label}-frameworks.sh"
end
embed_frameworks_script_relative_path() click to toggle source

@return [String] The path of the embed frameworks relative to the

root of the Pods project.
# File lib/cocoapods/target/aggregate_target.rb, line 307
def embed_frameworks_script_relative_path
  "${PODS_ROOT}/#{relative_to_pods_root(embed_frameworks_script_path)}"
end
framework_paths_by_config() click to toggle source

@return [Hash{String => Array<Hash{Symbol => [String]}>}] The vendored dynamic artifacts and framework target

input and output paths grouped by config
# File lib/cocoapods/target/aggregate_target.rb, line 197
def framework_paths_by_config
  @framework_paths_by_config ||= begin
    framework_paths_by_config = {}
    user_build_configurations.keys.each do |config|
      relevant_pod_targets = pod_targets_for_build_configuration(config)
      framework_paths_by_config[config] = relevant_pod_targets.flat_map do |pod_target|
        non_test_specs = pod_target.non_test_specs.map(&:name)
        pod_target.framework_paths.values_at(*non_test_specs).flatten.compact.uniq
      end
    end
    framework_paths_by_config
  end
end
label() click to toggle source

@return [String] the label for the target.

# File lib/cocoapods/target/aggregate_target.rb, line 121
def label
  target_definition.label.to_s
end
library?() click to toggle source

@return [Boolean] True if the user_target refers to a

library (framework, static or dynamic lib).
# File lib/cocoapods/target/aggregate_target.rb, line 94
def library?
  # Without a user_project, we can't say for sure
  # that this is a library
  return false if user_project.nil?
  symbol_types = user_targets.map(&:symbol_type).uniq
  raise ArgumentError, "Expected single kind of user_target for #{name}. Found #{symbol_types.join(', ')}." unless symbol_types.count == 1
  [:framework, :dynamic_library, :static_library].include? symbol_types.first
end
pod_targets_for_build_configuration(build_configuration) click to toggle source

@param [String] build_configuration The build configuration for which the

the pod targets should be returned.

@return [Array<PodTarget>] the pod targets for the given build

configuration.
# File lib/cocoapods/target/aggregate_target.rb, line 160
def pod_targets_for_build_configuration(build_configuration)
  @pod_targets_for_build_configuration[build_configuration] || []
end
podfile() click to toggle source

@return [Podfile] The podfile which declares the dependency

# File lib/cocoapods/target/aggregate_target.rb, line 127
def podfile
  target_definition.podfile
end
podfile_dir_relative_path() click to toggle source

@return [String] The path of the Podfile directory relative to the

root of the user project.
# File lib/cocoapods/target/aggregate_target.rb, line 282
def podfile_dir_relative_path
  podfile_path = target_definition.podfile.defined_in_file
  return "${SRCROOT}/#{podfile_path.relative_path_from(client_root).dirname}" unless podfile_path.nil?
  # Fallback to the standard path if the Podfile is not represented by a file.
  '${PODS_ROOT}/..'
end
relative_pods_root() click to toggle source

@return [String] The xcconfig path of the root from the `$(SRCROOT)`

variable of the user's project.
# File lib/cocoapods/target/aggregate_target.rb, line 275
def relative_pods_root
  "${SRCROOT}/#{relative_pods_root_path}"
end
relative_pods_root_path() click to toggle source

@return [Pathname] The relative path of the Pods directory from user project's directory.

# File lib/cocoapods/target/aggregate_target.rb, line 268
def relative_pods_root_path
  sandbox.root.relative_path_from(client_root)
end
requires_host_target?() click to toggle source

@return [Boolean] True if the user_target's pods are

for an extension and must be embedded in a host,
target, otherwise false.
# File lib/cocoapods/target/aggregate_target.rb, line 107
def requires_host_target?
  # If we don't have a user_project, then we can't
  # glean any info about how this target is going to
  # be integrated, so return false since we can't know
  # for sure that this target refers to an extension
  # target that would require a host target
  return false if user_project.nil?
  symbol_types = user_targets.map(&:symbol_type).uniq
  raise ArgumentError, "Expected single kind of user_target for #{name}. Found #{symbol_types.join(', ')}." unless symbol_types.count == 1
  EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include?(symbol_types[0])
end
resource_paths_by_config() click to toggle source

@return [Hash{String => Array<String>}] Uniqued Resources grouped by config

# File lib/cocoapods/target/aggregate_target.rb, line 213
def resource_paths_by_config
  @resource_paths_by_config ||= begin
    relevant_pod_targets = pod_targets.reject do |pod_target|
      pod_target.should_build? && pod_target.requires_frameworks? && !pod_target.static_framework?
    end
    user_build_configurations.keys.each_with_object({}) do |config, resources_by_config|
      resources_by_config[config] = (relevant_pod_targets & pod_targets_for_build_configuration(config)).flat_map do |pod_target|
        non_test_specs = pod_target.non_test_specs.map(&:name)
        resource_paths = pod_target.resource_paths.values_at(*non_test_specs).flatten.compact
        (resource_paths + [bridge_support_file].compact).uniq
      end
    end
  end
end
spec_consumers() click to toggle source

@return [Array<Specification::Consumer>] The consumers of the Pod.

# File lib/cocoapods/target/aggregate_target.rb, line 184
def spec_consumers
  specs.map { |spec| spec.consumer(platform) }
end
specs() click to toggle source

@return [Array<Specification>] The specifications used by this aggregate target.

# File lib/cocoapods/target/aggregate_target.rb, line 166
def specs
  pod_targets.flat_map(&:specs)
end
specs_by_build_configuration() click to toggle source

@return [Hash{Symbol => Array<Specification>}] The pod targets for each

build configuration.
# File lib/cocoapods/target/aggregate_target.rb, line 173
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_project_path() click to toggle source

@return [Pathname] the path of the user project that this target will

integrate as identified by the analyzer.
# File lib/cocoapods/target/aggregate_target.rb, line 134
def user_project_path
  user_project.path if user_project
end
user_targets() click to toggle source

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

@return [Array<PBXNativeTarget>]

# File lib/cocoapods/target/aggregate_target.rb, line 142
def user_targets
  return [] unless user_project
  user_target_uuids.map do |uuid|
    native_target = user_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?() click to toggle source

@return [Boolean] Whether the target uses Swift code

# File lib/cocoapods/target/aggregate_target.rb, line 190
def uses_swift?
  pod_targets.any?(&:uses_swift?)
end
xcconfig_relative_path(config_name) click to toggle source

@param [String] config_name The build configuration name to get the xcconfig for @return [String] The path of the xcconfig file relative to the root of

the user project.
# File lib/cocoapods/target/aggregate_target.rb, line 293
def xcconfig_relative_path(config_name)
  xcconfig_path(config_name).relative_path_from(client_root).to_s
end

Private Instance Methods

create_build_settings() click to toggle source
# File lib/cocoapods/target/aggregate_target.rb, line 328
def create_build_settings
  settings = {}

  user_build_configurations.each_key do |configuration_name|
    settings[configuration_name] = BuildSettings::AggregateTargetSettings.new(self, configuration_name)
  end

  settings
end
relative_to_pods_root(path) click to toggle source

Computes the relative path of a sandboxed file from the `$(PODS_ROOT)` variable of the Pods's project.

@param [Pathname] path

A relative path from the root of the sandbox.

@return [String] The computed path.

# File lib/cocoapods/target/aggregate_target.rb, line 324
def relative_to_pods_root(path)
  path.relative_path_from(sandbox.root).to_s
end