Class: Pod::PodTarget

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

Overview

Stores the information relative to the target used to compile a single Pod. A pod can have one or more activated spec/subspecs.

Instance Attribute Summary collapse

Attributes inherited from Target

#archs, #sandbox, #target, #target_definition, #user_build_configurations

Instance Method Summary collapse

Methods inherited from Target

#bridge_support_path, #dummy_source_path, #inspect, #name, #platform, #prefix_header_path, #product_name, #support_files_dir, #target_environment_header_path, #xcconfig_path, #xcconfig_prefix, #xcconfig_private_path

Constructor Details

#initialize(specs, target_definition, sandbox) ⇒ PodTarget

Returns a new instance of PodTarget.

Parameters:

  • spec (Specification)

    @see spec

  • target_definition (TargetDefinition)

    @see target_definition

  • sandbox (Sandbox)

    @see sandbox



18
19
20
21
22
23
24
# File 'lib/cocoapods/target/pod_target.rb', line 18

def initialize(specs, target_definition, sandbox)
  @specs = specs
  @target_definition = target_definition
  @sandbox = sandbox
  @build_headers  = Sandbox::HeadersStore.new(sandbox, 'Build')
  @file_accessors = []
end

Instance Attribute Details

#build_headersHeadersStore (readonly)

Returns the header directory for the target.

Returns:

  • (HeadersStore)

    the header directory for the target.



12
13
14
# File 'lib/cocoapods/target/pod_target.rb', line 12

def build_headers
  @build_headers
end

#file_accessorsArray<Sandbox::FileAccessor>

Returns the file accessors for the specifications of this target.

Returns:



35
36
37
# File 'lib/cocoapods/target/pod_target.rb', line 35

def file_accessors
  @file_accessors
end

#specsSpecification (readonly)

Returns the spec for the target.

Returns:



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

def specs
  @specs
end

Instance Method Details

#dependenciesArray<String>

Returns The names of the Pods on which this target depends.

Returns:

  • (Array<String>)

    The names of the Pods on which this target depends.



59
60
61
62
63
# File 'lib/cocoapods/target/pod_target.rb', line 59

def dependencies
  specs.map do |spec|
    spec.consumer(platform).dependencies.map { |dep| Specification.root_name(dep.name) }
  end.flatten
end

#include_in_build_config?(configuration_name) ⇒ Boolean

Checks if the target should be included in the build configuration with the given name.

Parameters:

  • configuration_name (String)

    The name of the build configuration.

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/cocoapods/target/pod_target.rb', line 71

def include_in_build_config?(configuration_name)
  whitelists = target_definition_dependencies.map do |dependency|
    target_definition.pod_whitelisted_for_configuration?(dependency.name, configuration_name)
  end.uniq

  if whitelists.empty?
    return true
  elsif whitelists.count == 1
    whitelists.first
  else
    raise Informative, "The subspecs of `#{pod_name}` are linked to " \
      "different build configurations for the `#{target_definition}` " \
      'target. CocoaPods does not currently support subspecs across ' \
      'different build configurations.'
  end
end

#labelString

Returns the label for the target.

Returns:

  • (String)

    the label for the target.



28
29
30
# File 'lib/cocoapods/target/pod_target.rb', line 28

def label
  "#{target_definition.label}-#{root_spec.name}"
end

#pod_nameString

Returns The name of the Pod that this target refers to.

Returns:

  • (String)

    The name of the Pod that this target refers to.



52
53
54
# File 'lib/cocoapods/target/pod_target.rb', line 52

def pod_name
  root_spec.name
end

#root_specSpecification

Returns The root specification for the target.

Returns:



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

def root_spec
  specs.first.root
end

#spec_consumersArray<Specification::Consumer>

Returns the specification consumers for the target.

Returns:

  • (Array<Specification::Consumer>)

    the specification consumers for the target.



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

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