Class: Pod::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/target.rb,
lib/cocoapods/target/build_settings.rb

Overview

Model class which describes a Pods target.

The Target class stores and provides the information necessary for working with a target in the Podfile and its dependent libraries. This class is used to represent both the targets and their libraries.

Direct Known Subclasses

AggregateTarget, PodTarget

Defined Under Namespace

Classes: BuildSettings

Constant Summary collapse

DEFAULT_VERSION =
'1.0.0'.freeze
DEFAULT_NAME =
'Default'.freeze
DEFAULT_BUILD_CONFIGURATIONS =
{ 'Release' => :release, 'Debug' => :debug }.freeze

Instance Attribute Summary collapse

Framework support collapse

Support files collapse

Instance Method Summary collapse

Constructor Details

#initialize(sandbox, host_requires_frameworks, user_build_configurations, archs, platform) ⇒ Target

Initialize a new target

Parameters:

  • sandbox (Sandbox)

    @see #sandbox

  • host_requires_frameworks (Boolean)

    @see #host_requires_frameworks

  • user_build_configurations (Hash{String=>Symbol})

    @see #user_build_configurations

  • archs (Array<String>)

    @see #archs

  • platform (Platform)

    @see #platform



51
52
53
54
55
56
57
58
59
# File 'lib/cocoapods/target.rb', line 51

def initialize(sandbox, host_requires_frameworks, user_build_configurations, archs, platform)
  @sandbox = sandbox
  @host_requires_frameworks = host_requires_frameworks
  @user_build_configurations = user_build_configurations
  @archs = archs
  @platform = platform

  @build_settings = create_build_settings
end

Instance Attribute Details

#archsArray<String> (readonly)

Returns The value for the ARCHS build setting.

Returns:

  • (Array<String>)

    The value for the ARCHS build setting.



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

def archs
  @archs
end

#build_settingsBuildSettings (readonly)

Returns the build settings for this target.

Returns:



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

def build_settings
  @build_settings
end

#host_requires_frameworksBoolean (readonly) Also known as: host_requires_frameworks?

Returns Whether the target needs to be implemented as a framework. Computed by analyzer.

Returns:

  • (Boolean)

    Whether the target needs to be implemented as a framework. Computed by analyzer.



22
23
24
# File 'lib/cocoapods/target.rb', line 22

def host_requires_frameworks
  @host_requires_frameworks
end

#platformPlatform (readonly)

Returns the platform of this target.

Returns:

  • (Platform)

    the platform of this target.



37
38
39
# File 'lib/cocoapods/target.rb', line 37

def platform
  @platform
end

#sandboxSandbox (readonly)

Returns The sandbox where the Pods should be installed.

Returns:

  • (Sandbox)

    The sandbox where the Pods should be installed.



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

def sandbox
  @sandbox
end

#user_build_configurationsHash{String=>Symbol} (readonly)

Returns A hash representing the user build configurations where each key corresponds to the name of a configuration and its value to its type (‘:debug` or `:release`).

Returns:

  • (Hash{String=>Symbol})

    A hash representing the user build configurations where each key corresponds to the name of a configuration and its value to its type (‘:debug` or `:release`).



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

def user_build_configurations
  @user_build_configurations
end

Instance Method Details

#bridge_support_pathPathname

Returns the absolute path of the bridge support file.

Returns:

  • (Pathname)

    the absolute path of the bridge support file.



223
224
225
# File 'lib/cocoapods/target.rb', line 223

def bridge_support_path
  support_files_dir + "#{label}.bridgesupport"
end

#dummy_source_pathPathname

Returns the path of the dummy source generated by CocoaPods.

Returns:

  • (Pathname)

    the path of the dummy source generated by CocoaPods



235
236
237
# File 'lib/cocoapods/target.rb', line 235

def dummy_source_path
  support_files_dir + "#{label}-dummy.m"
end

#framework_nameString

Note:

This may not depend on #requires_frameworks? indirectly as it is used for migration.

Returns the name of the framework, depends on #label.

Returns:

  • (String)

    the name of the framework, depends on #label.



128
129
130
# File 'lib/cocoapods/target.rb', line 128

def framework_name
  "#{product_module_name}.framework"
end

#info_plist_pathPathname

Returns the absolute path of the Info.plist file.

Returns:

  • (Pathname)

    the absolute path of the Info.plist file.



229
230
231
# File 'lib/cocoapods/target.rb', line 229

def info_plist_path
  support_files_dir + "#{label}-Info.plist"
end

#inspectString

Returns A string suitable for debugging.

Returns:

  • (String)

    A string suitable for debugging.



150
151
152
# File 'lib/cocoapods/target.rb', line 150

def inspect
  "<#{self.class} name=#{name} >"
end

#labelString

Returns the label for the target.

Returns:

  • (String)

    the label for the target.



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

def label
  DEFAULT_NAME
end

#module_map_pathPathname

Returns the absolute path of the LLVM module map file that defines the module structure for the compiler.

Returns:

  • (Pathname)

    the absolute path of the LLVM module map file that defines the module structure for the compiler.



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

def module_map_path
  module_map_path_to_write
end

#module_map_path_to_writePathname

Returns the absolute path of the module map file that CocoaPods writes. This can be different from ‘module_map_path` if the module map gets symlinked.

Returns:

  • (Pathname)

    the absolute path of the module map file that CocoaPods writes. This can be different from ‘module_map_path` if the module map gets symlinked.



216
217
218
219
# File 'lib/cocoapods/target.rb', line 216

def module_map_path_to_write
  basename = "#{label}.modulemap"
  support_files_dir + basename
end

#nameString Also known as: to_s

Returns the name of the library.

Returns:

  • (String)

    the name of the library.



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

def name
  label
end

#product_basenameString

Returns the name of the product excluding the file extension or a product type specific prefix, depends on #requires_frameworks? and #product_module_name or #label.

Returns:

  • (String)

    the name of the product excluding the file extension or a product type specific prefix, depends on #requires_frameworks? and #product_module_name or #label.



115
116
117
118
119
120
121
# File 'lib/cocoapods/target.rb', line 115

def product_basename
  if requires_frameworks?
    product_module_name
  else
    label
  end
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.



97
98
99
# File 'lib/cocoapods/target.rb', line 97

def product_module_name
  c99ext_identifier(label)
end

#product_nameString

Returns the name of the product.

Returns:

  • (String)

    the name of the product.



103
104
105
106
107
108
109
# File 'lib/cocoapods/target.rb', line 103

def product_name
  if requires_frameworks?
    framework_name
  else
    static_library_name
  end
end

#product_typeSymbol

Returns either :framework or :static_library, depends on #requires_frameworks?.

Returns:

  • (Symbol)

    either :framework or :static_library, depends on #requires_frameworks?.



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

def product_type
  requires_frameworks? ? :framework : :static_library
end

#requires_frameworks?Boolean

Returns whether the generated target needs to be implemented as a framework.

Returns:

  • (Boolean)

    whether the generated target needs to be implemented as a framework



161
162
163
# File 'lib/cocoapods/target.rb', line 161

def requires_frameworks?
  host_requires_frameworks? || false
end

#static_framework?Boolean

Returns Whether the target should build a static framework.

Returns:

  • (Boolean)

    Whether the target should build a static framework.



89
90
91
# File 'lib/cocoapods/target.rb', line 89

def static_framework?
  false
end

#static_library_nameString

Note:

This may not depend on #requires_frameworks? indirectly as it is used for migration.

Returns the name of the library, depends on #label.

Returns:

  • (String)

    the name of the library, depends on #label.



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

def static_library_name
  "lib#{label}.a"
end

#support_files_dirPathname

Returns the folder where to store the support files of this library.

Returns:

  • (Pathname)

    the folder where to store the support files of this library.



172
173
174
# File 'lib/cocoapods/target.rb', line 172

def support_files_dir
  sandbox.target_support_files_dir(name)
end

#umbrella_header_pathPathname

Returns the absolute path of the header file which contains the exported foundation constants with framework version information and all headers, which should been exported in the module map.

Returns:

  • (Pathname)

    the absolute path of the header file which contains the exported foundation constants with framework version information and all headers, which should been exported in the module map.



195
196
197
# File 'lib/cocoapods/target.rb', line 195

def umbrella_header_path
  module_map_path.parent + "#{label}-umbrella.h"
end

#umbrella_header_path_to_writeObject



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

def umbrella_header_path_to_write
  module_map_path_to_write.parent + "#{label}-umbrella.h"
end

#uses_swift?Boolean

Returns Whether the target uses Swift code.

Returns:

  • (Boolean)

    Whether the target uses Swift code



83
84
85
# File 'lib/cocoapods/target.rb', line 83

def uses_swift?
  false
end

#versionString

Returns The version associated with this target.

Returns:

  • (String)

    The version associated with this target



77
78
79
# File 'lib/cocoapods/target.rb', line 77

def version
  DEFAULT_VERSION
end

#xcconfig_path(variant = nil) ⇒ Pathname

Returns the absolute path of the xcconfig file.

Parameters:

  • variant (String) (defaults to: nil)

    The variant of the xcconfig. Used to differentiate build configurations.

Returns:

  • (Pathname)

    the absolute path of the xcconfig file.



182
183
184
185
186
187
188
# File 'lib/cocoapods/target.rb', line 182

def xcconfig_path(variant = nil)
  if variant
    support_files_dir + "#{label}.#{variant.gsub(File::SEPARATOR, '-').downcase}.xcconfig"
  else
    support_files_dir + "#{label}.xcconfig"
  end
end