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, build_type, user_build_configurations, archs, platform) ⇒ Target

Initialize a new target

Parameters:

  • sandbox (Sandbox)

    @see #sandbox

  • build_type (BuildType)

    @see #build_type

  • user_build_configurations (Hash{String=>Symbol})

    @see #user_build_configurations

  • archs (Array<String>)

    @see #archs

  • platform (Platform)

    @see #platform


54
55
56
57
58
59
60
61
62
63
# File 'lib/cocoapods/target.rb', line 54

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

  @application_extension_api_only = false
  @build_settings = create_build_settings
end

Instance Attribute Details

#application_extension_api_onlyBoolean (readonly)

Returns whether the target can be linked to app extensions only.

Returns:

  • (Boolean)

    whether the target can be linked to app extensions only.


44
45
46
# File 'lib/cocoapods/target.rb', line 44

def application_extension_api_only
  @application_extension_api_only
end

#archsArray<String> (readonly)

Returns The value for the ARCHS build setting.

Returns:

  • (Array<String>)

    The value for the ARCHS build setting.


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

def archs
  @archs
end

#build_settingsBuildSettings (readonly)

Returns the build settings for this target.

Returns:


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

def build_settings
  @build_settings
end

#platformPlatform (readonly)

Returns the platform of this target.

Returns:

  • (Platform)

    the platform of this target.


31
32
33
# File 'lib/cocoapods/target.rb', line 31

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`).


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

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.


279
280
281
# File 'lib/cocoapods/target.rb', line 279

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

#build_as_dynamic?Boolean

Returns whether the target is built dynamically.

Returns:

  • (Boolean)

    whether the target is built dynamically


93
94
95
# File 'lib/cocoapods/target.rb', line 93

def build_as_dynamic?
  build_type.dynamic?
end

#build_as_dynamic_framework?Boolean

Returns whether the target is built as a dynamic framework.

Returns:

  • (Boolean)

    whether the target is built as a dynamic framework


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

def build_as_dynamic_framework?
  build_type.dynamic_framework?
end

#build_as_dynamic_library?Boolean

Returns whether the target is built as a dynamic library.

Returns:

  • (Boolean)

    whether the target is built as a dynamic library


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

def build_as_dynamic_library?
  build_type.dynamic_library?
end

#build_as_framework?Boolean

Returns whether the target is built as a framework.

Returns:

  • (Boolean)

    whether the target is built as a framework


111
112
113
# File 'lib/cocoapods/target.rb', line 111

def build_as_framework?
  build_type.framework?
end

#build_as_library?Boolean

Returns whether the target is built as a library.

Returns:

  • (Boolean)

    whether the target is built as a library


117
118
119
# File 'lib/cocoapods/target.rb', line 117

def build_as_library?
  build_type.library?
end

#build_as_static?Boolean

Returns whether the target is built statically.

Returns:

  • (Boolean)

    whether the target is built statically


123
124
125
# File 'lib/cocoapods/target.rb', line 123

def build_as_static?
  build_type.static?
end

#build_as_static_framework?Boolean

Returns whether the target is built as a static framework.

Returns:

  • (Boolean)

    whether the target is built as a static framework


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

def build_as_static_framework?
  build_type.static_framework?
end

#build_as_static_library?Boolean

Returns whether the target is built as a static library.

Returns:

  • (Boolean)

    whether the target is built as a static library


135
136
137
# File 'lib/cocoapods/target.rb', line 135

def build_as_static_library?
  build_type.static_library?
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


297
298
299
# File 'lib/cocoapods/target.rb', line 297

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.


182
183
184
# File 'lib/cocoapods/target.rb', line 182

def framework_name
  "#{product_module_name}.framework"
end

#info_plist_entriesHash

Returns additional entries for the generated Info.plist.

Returns:

  • (Hash)

    additional entries for the generated Info.plist


291
292
293
# File 'lib/cocoapods/target.rb', line 291

def info_plist_entries
  {}
end

#info_plist_pathPathname

Returns the absolute path of the Info.plist file.

Returns:

  • (Pathname)

    the absolute path of the Info.plist file.


285
286
287
# File 'lib/cocoapods/target.rb', line 285

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.


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

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

#labelString

Returns the label for the target.

Returns:

  • (String)

    the label for the target.


75
76
77
# File 'lib/cocoapods/target.rb', line 75

def label
  DEFAULT_NAME
end

#mark_application_extension_api_onlyObject

mark the target as extension-only, translates to APPLICATION_EXTENSION_API_ONLY = YES in the build settings


304
305
306
# File 'lib/cocoapods/target.rb', line 304

def mark_application_extension_api_only
  @application_extension_api_only = true
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.


262
263
264
# File 'lib/cocoapods/target.rb', line 262

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.


272
273
274
275
# File 'lib/cocoapods/target.rb', line 272

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.


67
68
69
# File 'lib/cocoapods/target.rb', line 67

def name
  label
end

#prepare_artifacts_script_pathPathname

Returns The absolute path of the prepare artifacts script.

Returns:

  • (Pathname)

    The absolute path of the prepare artifacts script.


310
311
312
# File 'lib/cocoapods/target.rb', line 310

def prepare_artifacts_script_path
  support_files_dir + "#{label}-artifacts.sh"
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.


169
170
171
172
173
174
175
# File 'lib/cocoapods/target.rb', line 169

def product_basename
  if build_as_framework?
    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.


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

def product_module_name
  c99ext_identifier(label)
end

#product_nameString

Returns the name of the product.

Returns:

  • (String)

    the name of the product.


157
158
159
160
161
162
163
# File 'lib/cocoapods/target.rb', line 157

def product_name
  if build_as_framework?
    framework_name
  else
    static_library_name
  end
end

#product_typeSymbol

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

Returns:

  • (Symbol)

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


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

def product_type
  build_as_framework? ? :framework : :static_library
end

#requires_frameworks?Boolean

Deprecated.

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


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

def requires_frameworks?
  build_as_framework?
end

#static_framework?Boolean

Deprecated.

Returns Whether the target should build a static framework.

Returns:

  • (Boolean)

    Whether the target should build a static framework.


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

def static_framework?
  build_as_static_framework?
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.


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

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.


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

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.


251
252
253
# File 'lib/cocoapods/target.rb', line 251

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

#umbrella_header_path_to_writeObject


255
256
257
# File 'lib/cocoapods/target.rb', line 255

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


87
88
89
# File 'lib/cocoapods/target.rb', line 87

def uses_swift?
  false
end

#versionString

Returns The version associated with this target.

Returns:

  • (String)

    The version associated with this target


81
82
83
# File 'lib/cocoapods/target.rb', line 81

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.


238
239
240
241
242
243
244
# File 'lib/cocoapods/target.rb', line 238

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