class Pod::Target
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.
Constants
- DEFAULT_BUILD_CONFIGURATIONS
- DEFAULT_NAME
- DEFAULT_VERSION
Attributes
@return [Array<String>] The value for the ARCHS build setting.
@return [BuildSettings] the build settings for this target.
@return [Boolean] Whether the target needs to be implemented as a framework.
Computed by analyzer.
@return [Boolean] Whether the target needs to be implemented as a framework.
Computed by analyzer.
@return [Platform] the platform of this target.
@return [Sandbox] The sandbox where the Pods should be installed.
@return [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`).
Public Class Methods
Initialize a new target
@param [Sandbox] sandbox @see sandbox
@param [Boolean] host_requires_frameworks
@see host_requires_frameworks
@param [Hash{String=>Symbol}] user_build_configurations
@see user_build_configurations
@param [Array<String>] archs @see archs
@param [Platform] platform @see platform
# 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
Public Instance Methods
@return [Pathname] the absolute path of the bridge support file.
# File lib/cocoapods/target.rb, line 223 def bridge_support_path support_files_dir + "#{label}.bridgesupport" end
@return [Pathname] the path of the dummy source generated by CocoaPods
# File lib/cocoapods/target.rb, line 235 def dummy_source_path support_files_dir + "#{label}-dummy.m" end
@return [String] the name of the framework, depends on label
.
@note This may not depend on requires_frameworks?
indirectly as it is
used for migration.
# File lib/cocoapods/target.rb, line 128 def framework_name "#{product_module_name}.framework" end
@return [Pathname] the absolute path of the Info.plist file.
# File lib/cocoapods/target.rb, line 229 def info_plist_path support_files_dir + "#{label}-Info.plist" end
@return [String] A string suitable for debugging.
# File lib/cocoapods/target.rb, line 150 def inspect "<#{self.class} name=#{name} >" end
@return [String] the label for the target.
# File lib/cocoapods/target.rb, line 71 def label DEFAULT_NAME end
@return [Pathname] the absolute path of the LLVM module map file that
defines the module structure for the compiler.
# File lib/cocoapods/target.rb, line 206 def module_map_path module_map_path_to_write end
@!private
@return [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.
# File lib/cocoapods/target.rb, line 216 def module_map_path_to_write basename = "#{label}.modulemap" support_files_dir + basename end
@return [String] the name of the library.
# File lib/cocoapods/target.rb, line 63 def name label end
@return [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.
# File lib/cocoapods/target.rb, line 115 def product_basename if requires_frameworks? product_module_name else label end end
@return [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.
# File lib/cocoapods/target.rb, line 97 def product_module_name c99ext_identifier(label) end
@return [String] the name of the product.
# File lib/cocoapods/target.rb, line 103 def product_name if requires_frameworks? framework_name else static_library_name end end
@return [Symbol] either :framework or :static_library, depends on
#requires_frameworks?.
# File lib/cocoapods/target.rb, line 144 def product_type requires_frameworks? ? :framework : :static_library end
@return [Boolean] whether the generated target needs to be implemented
as a framework
# File lib/cocoapods/target.rb, line 161 def requires_frameworks? host_requires_frameworks? || false end
@return [Boolean] Whether the target should build a static framework.
# File lib/cocoapods/target.rb, line 89 def static_framework? false end
@return [String] the name of the library, depends on label
.
@note This may not depend on requires_frameworks?
indirectly as it is
used for migration.
# File lib/cocoapods/target.rb, line 137 def static_library_name "lib#{label}.a" end
@return [Pathname] the folder where to store the support files of this
library.
# File lib/cocoapods/target.rb, line 172 def support_files_dir sandbox.target_support_files_dir(name) end
@return [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.
# File lib/cocoapods/target.rb, line 195 def umbrella_header_path module_map_path.parent + "#{label}-umbrella.h" end
# File lib/cocoapods/target.rb, line 199 def umbrella_header_path_to_write module_map_path_to_write.parent + "#{label}-umbrella.h" end
@return [Boolean] Whether the target uses Swift code
# File lib/cocoapods/target.rb, line 83 def uses_swift? false end
@return [String] The version associated with this target
# File lib/cocoapods/target.rb, line 77 def version DEFAULT_VERSION end
@param [String] variant
The variant of the xcconfig. Used to differentiate build configurations.
@return [Pathname] the absolute path of the xcconfig file.
# 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
Private Instance Methods
Transforms the given string into a valid identifier
after C99ext standard, so that it can be used in source code where escaping of ambiguous characters is not applicable.
@param [String] name
any name, which may contain leading numbers, spaces or invalid characters.
@return [String]
# File lib/cocoapods/target.rb, line 253 def c99ext_identifier(name) name.gsub(/^([0-9])/, '_\1').gsub(/[^a-zA-Z0-9_]/, '_') end
# File lib/cocoapods/target.rb, line 257 def create_build_settings BuildSettings.new(self) end