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


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)


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

def application_extension_api_only
  @application_extension_api_only
end

#archsArray<String> (readonly)


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

def archs
  @archs
end

#build_settingsBuildSettings (readonly)


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

def build_settings
  @build_settings
end

#platformPlatform (readonly)


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

def platform
  @platform
end

#sandboxSandbox (readonly)


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

def sandbox
  @sandbox
end

#user_build_configurationsHash{String=>Symbol} (readonly)


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

def user_build_configurations
  @user_build_configurations
end

Instance Method Details

#bridge_support_pathPathname


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

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

#build_as_dynamic?Boolean


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

def build_as_dynamic?
  build_type.dynamic?
end

#build_as_dynamic_framework?Boolean


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


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

def build_as_dynamic_library?
  build_type.dynamic_library?
end

#build_as_framework?Boolean


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

def build_as_framework?
  build_type.framework?
end

#build_as_library?Boolean


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

def build_as_library?
  build_type.library?
end

#build_as_static?Boolean


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

def build_as_static?
  build_type.static?
end

#build_as_static_framework?Boolean


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


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

def build_as_static_library?
  build_type.static_library?
end

#dummy_source_pathPathname


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.


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

def framework_name
  "#{product_module_name}.framework"
end

#info_plist_entriesHash


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

def info_plist_entries
  {}
end

#info_plist_pathPathname


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

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

#inspectString


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

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

#labelString


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


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


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


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

def name
  label
end

#prepare_artifacts_script_pathPathname


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

def prepare_artifacts_script_path
  support_files_dir + "#{label}-artifacts.sh"
end

#product_basenameString


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


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

def product_module_name
  c99ext_identifier(label)
end

#product_nameString


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


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.


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.


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.


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

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

#support_files_dirPathname


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

def support_files_dir
  sandbox.target_support_files_dir(name)
end

#umbrella_header_pathPathname


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


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

def uses_swift?
  false
end

#versionString


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

def version
  DEFAULT_VERSION
end

#xcconfig_path(variant = nil) ⇒ Pathname


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