Class: Pod::Target
- Inherits:
-
Object
- Object
- Pod::Target
- 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
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
-
#application_extension_api_only ⇒ Boolean
readonly
Whether the target can be linked to app extensions only.
-
#archs ⇒ Array<String>
readonly
The value for the ARCHS build setting.
-
#build_library_for_distribution ⇒ Boolean
readonly
evolution support, necessary for XCFrameworks.
-
#build_settings ⇒ BuildSettings
readonly
The build settings for this target.
-
#platform ⇒ Platform
readonly
The platform of this target.
-
#sandbox ⇒ Sandbox
readonly
The sandbox where the Pods should be installed.
-
#user_build_configurations ⇒ Hash{String=>Symbol}
readonly
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`).
Framework support collapse
-
#requires_frameworks? ⇒ Boolean
deprecated
Deprecated.
Prefer #build_as_framework?.
Support files collapse
-
.output_extension_for_resource(input_extension) ⇒ String
Returns an extension in the target that corresponds to the resource’s input extension.
- .resource_extension_compilable?(input_extension) ⇒ Boolean
-
#bridge_support_path ⇒ Pathname
The absolute path of the bridge support file.
-
#dummy_source_path ⇒ Pathname
The path of the dummy source generated by CocoaPods.
-
#info_plist_entries ⇒ Hash
Additional entries for the generated Info.plist.
-
#info_plist_path ⇒ Pathname
The absolute path of the Info.plist file.
-
#mark_application_extension_api_only ⇒ Object
Mark the target as extension-only.
-
#mark_build_library_for_distribution ⇒ Object
Compiles the target with Swift’s library evolution support, necessary to build XCFrameworks.
-
#module_map_path ⇒ Pathname
The absolute path of the LLVM module map file that defines the module structure for the compiler.
-
#module_map_path_to_write ⇒ Pathname
The absolute path of the module map file that CocoaPods writes.
- #prepare_artifacts_script_path ⇒ Pathname deprecated Deprecated.
-
#support_files_dir ⇒ Pathname
The folder where to store the support files of this library.
-
#umbrella_header_path ⇒ 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.
- #umbrella_header_path_to_write ⇒ Object
-
#xcconfig_path(variant = nil) ⇒ Pathname
The absolute path of the xcconfig file.
Instance Method Summary collapse
-
#build_as_dynamic? ⇒ Boolean
Whether the target is built dynamically.
-
#build_as_dynamic_framework? ⇒ Boolean
Whether the target is built as a dynamic framework.
-
#build_as_dynamic_library? ⇒ Boolean
Whether the target is built as a dynamic library.
-
#build_as_framework? ⇒ Boolean
Whether the target is built as a framework.
-
#build_as_library? ⇒ Boolean
Whether the target is built as a library.
-
#build_as_static? ⇒ Boolean
Whether the target is built statically.
-
#build_as_static_framework? ⇒ Boolean
Whether the target is built as a static framework.
-
#build_as_static_library? ⇒ Boolean
Whether the target is built as a static library.
-
#framework_name ⇒ String
The name of the framework, depends on #label.
-
#initialize(sandbox, build_type, user_build_configurations, archs, platform) ⇒ Target
constructor
Initialize a new target.
-
#inspect ⇒ String
A string suitable for debugging.
-
#label ⇒ String
The label for the target.
-
#name ⇒ String
(also: #to_s)
The name of the library.
-
#product_basename ⇒ 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.
-
#product_module_name ⇒ 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.
-
#product_name ⇒ String
The name of the product.
-
#product_type ⇒ Symbol
Either :framework or :static_library, depends on #build_as_framework?.
-
#static_framework? ⇒ Boolean
deprecated
Deprecated.
Prefer #build_as_static_framework?.
-
#static_library_name ⇒ String
The name of the library, depends on #label.
-
#uses_swift? ⇒ Boolean
Whether the target uses Swift code.
-
#version ⇒ String
The version associated with this target.
Constructor Details
#initialize(sandbox, build_type, user_build_configurations, archs, platform) ⇒ Target
Initialize a new target
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cocoapods/target.rb', line 59 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_library_for_distribution = false @build_settings = create_build_settings end |
Instance Attribute Details
#application_extension_api_only ⇒ Boolean (readonly)
Returns 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 |
#archs ⇒ Array<String> (readonly)
Returns The value for the ARCHS build setting.
27 28 29 |
# File 'lib/cocoapods/target.rb', line 27 def archs @archs end |
#build_library_for_distribution ⇒ Boolean (readonly)
evolution support, necessary for XCFrameworks.
49 50 51 |
# File 'lib/cocoapods/target.rb', line 49 def build_library_for_distribution @build_library_for_distribution end |
#build_settings ⇒ BuildSettings (readonly)
Returns the build settings for this target.
35 36 37 |
# File 'lib/cocoapods/target.rb', line 35 def build_settings @build_settings end |
#platform ⇒ Platform (readonly)
Returns the platform of this target.
31 32 33 |
# File 'lib/cocoapods/target.rb', line 31 def platform @platform end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
17 18 19 |
# File 'lib/cocoapods/target.rb', line 17 def sandbox @sandbox end |
#user_build_configurations ⇒ Hash{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`).
23 24 25 |
# File 'lib/cocoapods/target.rb', line 23 def user_build_configurations @user_build_configurations end |
Class Method Details
.output_extension_for_resource(input_extension) ⇒ String
Returns an extension in the target that corresponds to the resource’s input extension.
340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/cocoapods/target.rb', line 340 def self.output_extension_for_resource(input_extension) case input_extension when '.storyboard' then '.storyboardc' when '.xib' then '.nib' when '.xcdatamodel' then '.mom' when '.xcdatamodeld' then '.momd' when '.xcmappingmodel' then '.cdm' when '.xcassets' then '.car' else input_extension end end |
.resource_extension_compilable?(input_extension) ⇒ Boolean
352 353 354 |
# File 'lib/cocoapods/target.rb', line 352 def self.resource_extension_compilable?(input_extension) output_extension_for_resource(input_extension) != input_extension && input_extension != '.xcassets' end |
Instance Method Details
#bridge_support_path ⇒ Pathname
Returns the absolute path of the bridge support file.
285 286 287 |
# File 'lib/cocoapods/target.rb', line 285 def bridge_support_path support_files_dir + "#{label}.bridgesupport" end |
#build_as_dynamic? ⇒ Boolean
Returns whether the target is built dynamically.
99 100 101 |
# File 'lib/cocoapods/target.rb', line 99 def build_as_dynamic? build_type.dynamic? end |
#build_as_dynamic_framework? ⇒ Boolean
Returns whether the target is built as a dynamic framework.
105 106 107 |
# File 'lib/cocoapods/target.rb', line 105 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.
111 112 113 |
# File 'lib/cocoapods/target.rb', line 111 def build_as_dynamic_library? build_type.dynamic_library? end |
#build_as_framework? ⇒ Boolean
Returns whether the target is built as a framework.
117 118 119 |
# File 'lib/cocoapods/target.rb', line 117 def build_as_framework? build_type.framework? end |
#build_as_library? ⇒ Boolean
Returns whether the target is built as a library.
123 124 125 |
# File 'lib/cocoapods/target.rb', line 123 def build_as_library? build_type.library? end |
#build_as_static? ⇒ Boolean
Returns whether the target is built statically.
129 130 131 |
# File 'lib/cocoapods/target.rb', line 129 def build_as_static? build_type.static? end |
#build_as_static_framework? ⇒ Boolean
Returns whether the target is built as a static framework.
135 136 137 |
# File 'lib/cocoapods/target.rb', line 135 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.
141 142 143 |
# File 'lib/cocoapods/target.rb', line 141 def build_as_static_library? build_type.static_library? end |
#dummy_source_path ⇒ Pathname
Returns the path of the dummy source generated by CocoaPods.
303 304 305 |
# File 'lib/cocoapods/target.rb', line 303 def dummy_source_path support_files_dir + "#{label}-dummy.m" end |
#framework_name ⇒ String
This may not depend on #requires_frameworks? indirectly as it is used for migration.
Returns the name of the framework, depends on #label.
188 189 190 |
# File 'lib/cocoapods/target.rb', line 188 def framework_name "#{product_module_name}.framework" end |
#info_plist_entries ⇒ Hash
Returns additional entries for the generated Info.plist.
297 298 299 |
# File 'lib/cocoapods/target.rb', line 297 def info_plist_entries {} end |
#info_plist_path ⇒ Pathname
Returns the absolute path of the Info.plist file.
291 292 293 |
# File 'lib/cocoapods/target.rb', line 291 def info_plist_path support_files_dir + "#{label}-Info.plist" end |
#inspect ⇒ String
Returns A string suitable for debugging.
210 211 212 |
# File 'lib/cocoapods/target.rb', line 210 def inspect "#<#{self.class} name=#{name}>" end |
#label ⇒ String
Returns the label for the target.
81 82 83 |
# File 'lib/cocoapods/target.rb', line 81 def label DEFAULT_NAME end |
#mark_application_extension_api_only ⇒ Object
Mark the target as extension-only. Translates to APPLICATION_EXTENSION_API_ONLY = YES in the build settings.
310 311 312 |
# File 'lib/cocoapods/target.rb', line 310 def mark_application_extension_api_only @application_extension_api_only = true end |
#mark_build_library_for_distribution ⇒ Object
Compiles the target with Swift’s library evolution support, necessary to build XCFrameworks. Translates to BUILD_LIBRARY_FOR_DISTRIBUTION = YES in the build settings.
318 319 320 |
# File 'lib/cocoapods/target.rb', line 318 def mark_build_library_for_distribution @build_library_for_distribution = true end |
#module_map_path ⇒ Pathname
Returns the absolute path of the LLVM module map file that defines the module structure for the compiler.
268 269 270 |
# File 'lib/cocoapods/target.rb', line 268 def module_map_path module_map_path_to_write end |
#module_map_path_to_write ⇒ Pathname
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.
278 279 280 281 |
# File 'lib/cocoapods/target.rb', line 278 def module_map_path_to_write basename = "#{label}.modulemap" support_files_dir + basename end |
#name ⇒ String Also known as: to_s
Returns the name of the library.
73 74 75 |
# File 'lib/cocoapods/target.rb', line 73 def name label end |
#prepare_artifacts_script_path ⇒ Pathname
Remove in 2.0
Returns The absolute path of the prepare artifacts script.
328 329 330 |
# File 'lib/cocoapods/target.rb', line 328 def prepare_artifacts_script_path support_files_dir + "#{label}-artifacts.sh" end |
#product_basename ⇒ String
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.
175 176 177 178 179 180 181 |
# File 'lib/cocoapods/target.rb', line 175 def product_basename if build_as_framework? product_module_name else label end end |
#product_module_name ⇒ String
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.
157 158 159 |
# File 'lib/cocoapods/target.rb', line 157 def product_module_name c99ext_identifier(label) end |
#product_name ⇒ String
Returns the name of the product.
163 164 165 166 167 168 169 |
# File 'lib/cocoapods/target.rb', line 163 def product_name if build_as_framework? framework_name else static_library_name end end |
#product_type ⇒ Symbol
Returns either :framework or :static_library, depends on #build_as_framework?.
204 205 206 |
# File 'lib/cocoapods/target.rb', line 204 def product_type build_as_framework? ? :framework : :static_library end |
#requires_frameworks? ⇒ Boolean
Prefer #build_as_framework?.
Returns whether the generated target needs to be implemented as a framework.
223 224 225 |
# File 'lib/cocoapods/target.rb', line 223 def requires_frameworks? build_as_framework? end |
#static_framework? ⇒ Boolean
Prefer #build_as_static_framework?.
Returns Whether the target should build a static framework.
149 150 151 |
# File 'lib/cocoapods/target.rb', line 149 def static_framework? build_as_static_framework? end |
#static_library_name ⇒ String
This may not depend on #requires_frameworks? indirectly as it is used for migration.
Returns the name of the library, depends on #label.
197 198 199 |
# File 'lib/cocoapods/target.rb', line 197 def static_library_name "lib#{label}.a" end |
#support_files_dir ⇒ Pathname
Returns the folder where to store the support files of this library.
234 235 236 |
# File 'lib/cocoapods/target.rb', line 234 def support_files_dir sandbox.target_support_files_dir(name) end |
#umbrella_header_path ⇒ Pathname
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.
257 258 259 |
# File 'lib/cocoapods/target.rb', line 257 def umbrella_header_path module_map_path.parent + "#{label}-umbrella.h" end |
#umbrella_header_path_to_write ⇒ Object
261 262 263 |
# File 'lib/cocoapods/target.rb', line 261 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.
93 94 95 |
# File 'lib/cocoapods/target.rb', line 93 def uses_swift? false end |
#version ⇒ String
Returns The version associated with this target.
87 88 89 |
# File 'lib/cocoapods/target.rb', line 87 def version DEFAULT_VERSION end |
#xcconfig_path(variant = nil) ⇒ Pathname
Returns the absolute path of the xcconfig file.
244 245 246 247 248 249 250 |
# File 'lib/cocoapods/target.rb', line 244 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 |