xcocoapods 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6303 -0
  3. data/LICENSE +28 -0
  4. data/README.md +80 -0
  5. data/bin/pod +56 -0
  6. data/bin/sandbox-pod +168 -0
  7. data/lib/cocoapods.rb +73 -0
  8. data/lib/cocoapods/command.rb +175 -0
  9. data/lib/cocoapods/command/cache.rb +28 -0
  10. data/lib/cocoapods/command/cache/clean.rb +90 -0
  11. data/lib/cocoapods/command/cache/list.rb +69 -0
  12. data/lib/cocoapods/command/env.rb +66 -0
  13. data/lib/cocoapods/command/init.rb +128 -0
  14. data/lib/cocoapods/command/install.rb +45 -0
  15. data/lib/cocoapods/command/ipc.rb +19 -0
  16. data/lib/cocoapods/command/ipc/list.rb +40 -0
  17. data/lib/cocoapods/command/ipc/podfile.rb +31 -0
  18. data/lib/cocoapods/command/ipc/podfile_json.rb +30 -0
  19. data/lib/cocoapods/command/ipc/repl.rb +51 -0
  20. data/lib/cocoapods/command/ipc/spec.rb +29 -0
  21. data/lib/cocoapods/command/ipc/update_search_index.rb +24 -0
  22. data/lib/cocoapods/command/lib.rb +11 -0
  23. data/lib/cocoapods/command/lib/create.rb +105 -0
  24. data/lib/cocoapods/command/lib/lint.rb +121 -0
  25. data/lib/cocoapods/command/list.rb +39 -0
  26. data/lib/cocoapods/command/options/project_directory.rb +36 -0
  27. data/lib/cocoapods/command/options/repo_update.rb +34 -0
  28. data/lib/cocoapods/command/outdated.rb +140 -0
  29. data/lib/cocoapods/command/repo.rb +29 -0
  30. data/lib/cocoapods/command/repo/add.rb +103 -0
  31. data/lib/cocoapods/command/repo/lint.rb +82 -0
  32. data/lib/cocoapods/command/repo/list.rb +93 -0
  33. data/lib/cocoapods/command/repo/push.rb +281 -0
  34. data/lib/cocoapods/command/repo/remove.rb +36 -0
  35. data/lib/cocoapods/command/repo/update.rb +28 -0
  36. data/lib/cocoapods/command/setup.rb +103 -0
  37. data/lib/cocoapods/command/spec.rb +112 -0
  38. data/lib/cocoapods/command/spec/cat.rb +51 -0
  39. data/lib/cocoapods/command/spec/create.rb +283 -0
  40. data/lib/cocoapods/command/spec/edit.rb +87 -0
  41. data/lib/cocoapods/command/spec/env_spec.rb +53 -0
  42. data/lib/cocoapods/command/spec/lint.rb +137 -0
  43. data/lib/cocoapods/command/spec/which.rb +43 -0
  44. data/lib/cocoapods/command/update.rb +101 -0
  45. data/lib/cocoapods/config.rb +347 -0
  46. data/lib/cocoapods/core_overrides.rb +1 -0
  47. data/lib/cocoapods/downloader.rb +190 -0
  48. data/lib/cocoapods/downloader/cache.rb +233 -0
  49. data/lib/cocoapods/downloader/request.rb +86 -0
  50. data/lib/cocoapods/downloader/response.rb +16 -0
  51. data/lib/cocoapods/executable.rb +222 -0
  52. data/lib/cocoapods/external_sources.rb +57 -0
  53. data/lib/cocoapods/external_sources/abstract_external_source.rb +205 -0
  54. data/lib/cocoapods/external_sources/downloader_source.rb +30 -0
  55. data/lib/cocoapods/external_sources/path_source.rb +55 -0
  56. data/lib/cocoapods/external_sources/podspec_source.rb +54 -0
  57. data/lib/cocoapods/gem_version.rb +5 -0
  58. data/lib/cocoapods/generator/acknowledgements.rb +107 -0
  59. data/lib/cocoapods/generator/acknowledgements/markdown.rb +44 -0
  60. data/lib/cocoapods/generator/acknowledgements/plist.rb +94 -0
  61. data/lib/cocoapods/generator/app_target_helper.rb +244 -0
  62. data/lib/cocoapods/generator/bridge_support.rb +22 -0
  63. data/lib/cocoapods/generator/constant.rb +19 -0
  64. data/lib/cocoapods/generator/copy_resources_script.rb +230 -0
  65. data/lib/cocoapods/generator/dummy_source.rb +31 -0
  66. data/lib/cocoapods/generator/embed_frameworks_script.rb +215 -0
  67. data/lib/cocoapods/generator/header.rb +103 -0
  68. data/lib/cocoapods/generator/info_plist_file.rb +116 -0
  69. data/lib/cocoapods/generator/module_map.rb +99 -0
  70. data/lib/cocoapods/generator/prefix_header.rb +60 -0
  71. data/lib/cocoapods/generator/umbrella_header.rb +46 -0
  72. data/lib/cocoapods/hooks_manager.rb +132 -0
  73. data/lib/cocoapods/installer.rb +703 -0
  74. data/lib/cocoapods/installer/analyzer.rb +972 -0
  75. data/lib/cocoapods/installer/analyzer/analysis_result.rb +87 -0
  76. data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +98 -0
  77. data/lib/cocoapods/installer/analyzer/pod_variant.rb +67 -0
  78. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +157 -0
  79. data/lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb +54 -0
  80. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +240 -0
  81. data/lib/cocoapods/installer/analyzer/specs_state.rb +84 -0
  82. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +53 -0
  83. data/lib/cocoapods/installer/analyzer/target_inspector.rb +260 -0
  84. data/lib/cocoapods/installer/installation_options.rb +158 -0
  85. data/lib/cocoapods/installer/pod_source_installer.rb +202 -0
  86. data/lib/cocoapods/installer/pod_source_preparer.rb +77 -0
  87. data/lib/cocoapods/installer/podfile_validator.rb +139 -0
  88. data/lib/cocoapods/installer/post_install_hooks_context.rb +132 -0
  89. data/lib/cocoapods/installer/pre_install_hooks_context.rb +51 -0
  90. data/lib/cocoapods/installer/source_provider_hooks_context.rb +34 -0
  91. data/lib/cocoapods/installer/user_project_integrator.rb +250 -0
  92. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +463 -0
  93. data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +146 -0
  94. data/lib/cocoapods/installer/xcode.rb +8 -0
  95. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +416 -0
  96. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +181 -0
  97. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +84 -0
  98. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +334 -0
  99. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +777 -0
  100. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +116 -0
  101. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +86 -0
  102. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +256 -0
  103. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +68 -0
  104. data/lib/cocoapods/installer/xcode/target_validator.rb +147 -0
  105. data/lib/cocoapods/open-uri.rb +33 -0
  106. data/lib/cocoapods/project.rb +414 -0
  107. data/lib/cocoapods/resolver.rb +585 -0
  108. data/lib/cocoapods/resolver/lazy_specification.rb +79 -0
  109. data/lib/cocoapods/sandbox.rb +404 -0
  110. data/lib/cocoapods/sandbox/file_accessor.rb +444 -0
  111. data/lib/cocoapods/sandbox/headers_store.rb +146 -0
  112. data/lib/cocoapods/sandbox/path_list.rb +220 -0
  113. data/lib/cocoapods/sandbox/pod_dir_cleaner.rb +85 -0
  114. data/lib/cocoapods/sandbox/podspec_finder.rb +23 -0
  115. data/lib/cocoapods/sources_manager.rb +157 -0
  116. data/lib/cocoapods/target.rb +261 -0
  117. data/lib/cocoapods/target/aggregate_target.rb +338 -0
  118. data/lib/cocoapods/target/build_settings.rb +1075 -0
  119. data/lib/cocoapods/target/pod_target.rb +559 -0
  120. data/lib/cocoapods/user_interface.rb +459 -0
  121. data/lib/cocoapods/user_interface/error_report.rb +187 -0
  122. data/lib/cocoapods/user_interface/inspector_reporter.rb +109 -0
  123. data/lib/cocoapods/validator.rb +981 -0
  124. metadata +533 -0
@@ -0,0 +1,559 @@
1
+ module Pod
2
+ # Stores the information relative to the target used to compile a single Pod.
3
+ # A pod can have one or more activated spec, subspecs and test specs.
4
+ #
5
+ class PodTarget < Target
6
+ # @return [Array<Specification>] the spec, subspecs and test specs of the target.
7
+ #
8
+ attr_reader :specs
9
+
10
+ # @return [Array<Specification>] All of the test specs within this target.
11
+ # Subset of #specs.
12
+ #
13
+ attr_reader :test_specs
14
+
15
+ # @return [Array<Specification>] All of the specs within this target that are not test specs.
16
+ # Subset of #specs.
17
+ #
18
+ attr_reader :non_test_specs
19
+
20
+ # @return [Array<TargetDefinition>] the target definitions of the Podfile
21
+ # that generated this target.
22
+ #
23
+ attr_reader :target_definitions
24
+
25
+ # @return [Array<Sandbox::FileAccessor>] the file accessors for the
26
+ # specifications of this target.
27
+ #
28
+ attr_reader :file_accessors
29
+
30
+ # @return [String] the suffix used for this target when deduplicated. May be `nil`.
31
+ #
32
+ # @note This affects the value returned by #configuration_build_dir
33
+ # and accessors relying on this as #build_product_path.
34
+ #
35
+ attr_reader :scope_suffix
36
+
37
+ # @return [HeadersStore] the header directory for the target.
38
+ #
39
+ attr_reader :build_headers
40
+
41
+ # @return [Array<PodTarget>] the targets that this target has a dependency
42
+ # upon.
43
+ #
44
+ attr_accessor :dependent_targets
45
+
46
+ # @return [Hash{String=>Array<PodTarget>}] all target dependencies by test spec name.
47
+ #
48
+ attr_accessor :test_dependent_targets_by_spec_name
49
+
50
+ # Initialize a new instance
51
+ #
52
+ # @param [Sandbox] sandbox @see Target#sandbox
53
+ # @param [Boolean] host_requires_frameworks @see Target#host_requires_frameworks
54
+ # @param [Hash{String=>Symbol}] user_build_configurations @see Target#user_build_configurations
55
+ # @param [Array<String>] archs @see Target#archs
56
+ # @param [Platform] platform @see Target#platform
57
+ # @param [Array<TargetDefinition>] target_definitions @see #target_definitions
58
+ # @param [Array<Sandbox::FileAccessor>] file_accessors @see #file_accessors
59
+ # @param [String] scope_suffix @see #scope_suffix
60
+ #
61
+ def initialize(sandbox, host_requires_frameworks, user_build_configurations, archs, platform, specs,
62
+ target_definitions, file_accessors = [], scope_suffix = nil)
63
+ super(sandbox, host_requires_frameworks, user_build_configurations, archs, platform)
64
+ raise "Can't initialize a PodTarget without specs!" if specs.nil? || specs.empty?
65
+ raise "Can't initialize a PodTarget without TargetDefinition!" if target_definitions.nil? || target_definitions.empty?
66
+ raise "Can't initialize a PodTarget with only abstract TargetDefinitions!" if target_definitions.all?(&:abstract?)
67
+ raise "Can't initialize a PodTarget with an empty string scope suffix!" if scope_suffix == ''
68
+ @specs = specs.dup.freeze
69
+ @target_definitions = target_definitions
70
+ @file_accessors = file_accessors
71
+ @scope_suffix = scope_suffix
72
+ @test_specs, @non_test_specs = @specs.partition(&:test_specification?)
73
+ @build_headers = Sandbox::HeadersStore.new(sandbox, 'Private', :private)
74
+ @dependent_targets = []
75
+ @test_dependent_targets_by_spec_name = {}
76
+ @build_config_cache = {}
77
+ end
78
+
79
+ # Scopes the current target based on the existing pod targets within the cache.
80
+ #
81
+ # @param [Hash{Array => PodTarget}] cache
82
+ # the cached target for a previously scoped target.
83
+ #
84
+ # @return [Array<PodTarget>] a scoped copy for each target definition.
85
+ #
86
+ def scoped(cache = {})
87
+ target_definitions.map do |target_definition|
88
+ cache_key = [specs, target_definition]
89
+ if cache[cache_key]
90
+ cache[cache_key]
91
+ else
92
+ target = PodTarget.new(sandbox, host_requires_frameworks, user_build_configurations, archs, platform, specs, [target_definition], file_accessors, target_definition.label)
93
+ target.dependent_targets = dependent_targets.flat_map { |pt| pt.scoped(cache) }.select { |pt| pt.target_definitions == [target_definition] }
94
+ target.test_dependent_targets_by_spec_name = Hash[test_dependent_targets_by_spec_name.map do |spec_name, test_pod_targets|
95
+ scoped_test_pod_targets = test_pod_targets.flat_map do |test_pod_target|
96
+ test_pod_target.scoped(cache).select { |pt| pt.target_definitions == [target_definition] }
97
+ end
98
+ [spec_name, scoped_test_pod_targets]
99
+ end]
100
+ cache[cache_key] = target
101
+ end
102
+ end
103
+ end
104
+
105
+ # @return [String] the label for the target.
106
+ #
107
+ def label
108
+ if scope_suffix.nil? || scope_suffix[0] == '.'
109
+ "#{root_spec.name}#{scope_suffix}"
110
+ else
111
+ "#{root_spec.name}-#{scope_suffix}"
112
+ end
113
+ end
114
+
115
+ # @return [String] the Swift version for the target. If the pod author has provided a swift version
116
+ # then that is the one returned, otherwise the Swift version is determined by the user
117
+ # targets that include this pod target.
118
+ #
119
+ def swift_version
120
+ spec_swift_version || target_definitions.map(&:swift_version).compact.uniq.first
121
+ end
122
+
123
+ # @return [String] the Swift version within the root spec. Might be `nil` if none is set.
124
+ #
125
+ def spec_swift_version
126
+ root_spec.swift_version
127
+ end
128
+
129
+ # @return [Podfile] The podfile which declares the dependency.
130
+ #
131
+ def podfile
132
+ target_definitions.first.podfile
133
+ end
134
+
135
+ # @return [String] The name to use for the source code module constructed
136
+ # for this target, and which will be used to import the module in
137
+ # implementation source files.
138
+ #
139
+ def product_module_name
140
+ root_spec.module_name
141
+ end
142
+
143
+ # @return [Bool] Whether or not this target should be built.
144
+ #
145
+ # A target should not be built if it has no source files.
146
+ #
147
+ def should_build?
148
+ return @should_build if defined? @should_build
149
+ accessors = file_accessors.reject { |fa| fa.spec.test_specification? }
150
+ source_files = accessors.flat_map(&:source_files)
151
+ source_files -= accessors.flat_map(&:headers)
152
+ @should_build = !source_files.empty?
153
+ end
154
+
155
+ # @return [Array<Specification::Consumer>] the specification consumers for
156
+ # the target.
157
+ #
158
+ def spec_consumers
159
+ specs.map { |spec| spec.consumer(platform) }
160
+ end
161
+
162
+ # @return [Array<Specification::Consumer>] the test specification consumers for
163
+ # the target.
164
+ #
165
+ def test_spec_consumers
166
+ test_specs.map { |test_spec| test_spec.consumer(platform) }
167
+ end
168
+
169
+ # @return [Boolean] Whether the target uses Swift code.
170
+ #
171
+ def uses_swift?
172
+ return @uses_swift if defined? @uses_swift
173
+ @uses_swift = begin
174
+ file_accessors.reject { |a| a.spec.test_specification? }.any? do |file_accessor|
175
+ file_accessor.source_files.any? { |sf| sf.extname == '.swift' }
176
+ end
177
+ end
178
+ end
179
+
180
+ # Checks whether a particular test type uses Swift or not.
181
+ #
182
+ # @param [Symbol] test_type
183
+ # The test type to check whether it uses Swift or not.
184
+ #
185
+ # @return [Boolean] Whether the target uses Swift code in the specified test type.
186
+ #
187
+ def uses_swift_for_test_type?(test_type)
188
+ @uses_swift_for_test_type ||= {}
189
+ return @uses_swift_for_test_type[test_type] if @uses_swift_for_test_type.key?(test_type)
190
+ @uses_swift_for_test_type[test_type] = begin
191
+ file_accessors.select { |a| a.spec.test_specification? && a.spec.test_type == test_type }.any? do |file_accessor|
192
+ file_accessor.source_files.any? { |sf| sf.extname == '.swift' }
193
+ end
194
+ end
195
+ end
196
+
197
+ # @return [Boolean] Whether the target should build a static framework.
198
+ #
199
+ def static_framework?
200
+ requires_frameworks? && root_spec.static_framework
201
+ end
202
+
203
+ # @return [Boolean] Whether the target defines a "module"
204
+ # (and thus will need a module map and umbrella header).
205
+ #
206
+ # @note Static library targets can temporarily opt in to this behavior by setting
207
+ # `DEFINES_MODULE = YES` in their specification's `pod_target_xcconfig`.
208
+ #
209
+ def defines_module?
210
+ return @defines_module if defined?(@defines_module)
211
+ return @defines_module = true if uses_swift? || requires_frameworks?
212
+ return @defines_module = true if target_definitions.all? { |td| td.build_pod_as_module?(pod_name) }
213
+
214
+ @defines_module = non_test_specs.any? { |s| s.consumer(platform).pod_target_xcconfig['DEFINES_MODULE'] == 'YES' }
215
+ end
216
+
217
+ # @return [Array<Hash{Symbol=>String}>] An array of hashes where each hash represents a single script phase.
218
+ #
219
+ def script_phases
220
+ spec_consumers.flat_map(&:script_phases)
221
+ end
222
+
223
+ # @return [Boolean] Whether the target contains any script phases.
224
+ #
225
+ def contains_script_phases?
226
+ !script_phases.empty?
227
+ end
228
+
229
+ # @return [Boolean] Whether the target has any tests specifications.
230
+ #
231
+ def contains_test_specifications?
232
+ !test_specs.empty?
233
+ end
234
+
235
+ # @return [Array<Symbol>] All of the test supported types within this target.
236
+ #
237
+ def supported_test_types
238
+ test_specs.map(&:test_type).uniq
239
+ end
240
+
241
+ # @return [Hash{String=>Array<Hash{Symbol=>String}>}] The vendored and non vendored framework paths this target
242
+ # depends upon keyed by spec name. For the root spec and subspecs the framework path of the target itself
243
+ # is included.
244
+ #
245
+ def framework_paths
246
+ @framework_paths ||= begin
247
+ file_accessors.each_with_object({}) do |file_accessor, hash|
248
+ frameworks = []
249
+ file_accessor.vendored_dynamic_artifacts.map do |framework_path|
250
+ relative_path_to_sandbox = framework_path.relative_path_from(sandbox.root)
251
+ framework = { :name => framework_path.basename.to_s,
252
+ :input_path => "${PODS_ROOT}/#{relative_path_to_sandbox}",
253
+ :output_path => "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{framework_path.basename}" }
254
+ # Until this can be configured, assume the dSYM file uses the file name as the framework.
255
+ # See https://github.com/CocoaPods/CocoaPods/issues/1698
256
+ dsym_name = "#{framework_path.basename}.dSYM"
257
+ dsym_path = Pathname.new("#{framework_path.dirname}/#{dsym_name}")
258
+ if dsym_path.exist?
259
+ framework[:dsym_name] = dsym_name
260
+ framework[:dsym_input_path] = "${PODS_ROOT}/#{relative_path_to_sandbox}.dSYM"
261
+ framework[:dsym_output_path] = "${DWARF_DSYM_FOLDER_PATH}/#{dsym_name}"
262
+ end
263
+ frameworks << framework
264
+ end
265
+ if !file_accessor.spec.test_specification? && should_build? && requires_frameworks? && !static_framework?
266
+ frameworks << { :name => product_name,
267
+ :input_path => build_product_path('${BUILT_PRODUCTS_DIR}'),
268
+ :output_path => "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{product_name}" }
269
+ end
270
+ hash[file_accessor.spec.name] = frameworks
271
+ end
272
+ end
273
+ end
274
+
275
+ # @return [Hash{String=>Array<String>}] The resource and resource bundle paths this target depends upon keyed by
276
+ # spec name.
277
+ #
278
+ def resource_paths
279
+ @resource_paths ||= begin
280
+ file_accessors.each_with_object({}) do |file_accessor, hash|
281
+ resource_paths = file_accessor.resources.map { |res| "${PODS_ROOT}/#{res.relative_path_from(sandbox.project.path.dirname)}" }
282
+ prefix = Pod::Target::BuildSettings::CONFIGURATION_BUILD_DIR_VARIABLE
283
+ prefix = configuration_build_dir unless file_accessor.spec.test_specification?
284
+ resource_bundle_paths = file_accessor.resource_bundles.keys.map { |name| "#{prefix}/#{name.shellescape}.bundle" }
285
+ hash[file_accessor.spec.name] = resource_paths + resource_bundle_paths
286
+ end
287
+ end
288
+ end
289
+
290
+ # Returns the corresponding native product type to use given the test type.
291
+ # This is primarily used when creating the native targets in order to produce the correct test bundle target
292
+ # based on the type of tests included.
293
+ #
294
+ # @param [Symbol] test_type
295
+ # The test type to map to provided by the test specification DSL.
296
+ #
297
+ # @return [Symbol] The native product type to use.
298
+ #
299
+ def product_type_for_test_type(test_type)
300
+ case test_type
301
+ when :unit
302
+ :unit_test_bundle
303
+ else
304
+ raise Informative, "Unknown test type `#{test_type}`."
305
+ end
306
+ end
307
+
308
+ # Returns the corresponding test type given the product type.
309
+ #
310
+ # @param [Symbol] product_type
311
+ # The product type to map to a test type.
312
+ #
313
+ # @return [Symbol] The native product type to use.
314
+ #
315
+ def test_type_for_product_type(product_type)
316
+ case product_type
317
+ when :unit_test_bundle
318
+ :unit
319
+ else
320
+ raise Informative, "Unknown product type `#{product_type}`."
321
+ end
322
+ end
323
+
324
+ # @return [Specification] The root specification for the target.
325
+ #
326
+ def root_spec
327
+ specs.first.root
328
+ end
329
+
330
+ # @return [String] The name of the Pod that this target refers to.
331
+ #
332
+ def pod_name
333
+ root_spec.name
334
+ end
335
+
336
+ # @return [Pathname] the absolute path of the LLVM module map file that
337
+ # defines the module structure for the compiler.
338
+ #
339
+ def module_map_path
340
+ basename = "#{label}.modulemap"
341
+ if requires_frameworks?
342
+ super
343
+ elsif file_accessors.any?(&:module_map)
344
+ build_headers.root + product_module_name + basename
345
+ else
346
+ sandbox.public_headers.root + product_module_name + basename
347
+ end
348
+ end
349
+
350
+ # @param [String] bundle_name
351
+ # The name of the bundle product, which is given by the +spec+.
352
+ #
353
+ # @return [String] The derived name of the resource bundle target.
354
+ #
355
+ def resources_bundle_target_label(bundle_name)
356
+ "#{label}-#{bundle_name}"
357
+ end
358
+
359
+ # @param [Symbol] test_type
360
+ # The test type to use for producing the test label.
361
+ #
362
+ # @return [String] The derived name of the test target.
363
+ #
364
+ def test_target_label(test_type)
365
+ "#{label}-#{test_type.capitalize}-Tests"
366
+ end
367
+
368
+ # @param [Symbol] test_type
369
+ # The test type this embed frameworks script path is for.
370
+ #
371
+ # @return [Pathname] The absolute path of the copy resources script for the given test type.
372
+ #
373
+ def copy_resources_script_path_for_test_type(test_type)
374
+ support_files_dir + "#{test_target_label(test_type)}-resources.sh"
375
+ end
376
+
377
+ # @param [Symbol] test_type
378
+ # The test type this embed frameworks script path is for.
379
+ #
380
+ # @return [Pathname] The absolute path of the embed frameworks script for the given test type.
381
+ #
382
+ def embed_frameworks_script_path_for_test_type(test_type)
383
+ support_files_dir + "#{test_target_label(test_type)}-frameworks.sh"
384
+ end
385
+
386
+ # @param [Symbol] test_type
387
+ # The test type this Info.plist path is for.
388
+ #
389
+ # @return [Pathname] The absolute path of the Info.plist for the given test type.
390
+ #
391
+ def info_plist_path_for_test_type(test_type)
392
+ support_files_dir + "#{test_target_label(test_type)}-Info.plist"
393
+ end
394
+
395
+ # @return [Pathname] the absolute path of the prefix header file.
396
+ #
397
+ def prefix_header_path
398
+ support_files_dir + "#{label}-prefix.pch"
399
+ end
400
+
401
+ # @param [Symbol] test_type
402
+ # The test type prefix header path is for.
403
+ #
404
+ # @return [Pathname] the absolute path of the prefix header file for the given test type.
405
+ #
406
+ def prefix_header_path_for_test_type(test_type)
407
+ support_files_dir + "#{test_target_label(test_type)}-prefix.pch"
408
+ end
409
+
410
+ # @return [Array<String>] The names of the Pods on which this target
411
+ # depends.
412
+ #
413
+ def dependencies
414
+ spec_consumers.flat_map do |consumer|
415
+ consumer.dependencies.map { |dep| Specification.root_name(dep.name) }
416
+ end.uniq
417
+ end
418
+
419
+ # @return [Array<PodTarget>] the recursive targets that this target has a
420
+ # dependency upon.
421
+ #
422
+ def recursive_dependent_targets
423
+ @recursive_dependent_targets ||= _add_recursive_dependent_targets(Set.new).delete(self).to_a
424
+ end
425
+
426
+ def _add_recursive_dependent_targets(set)
427
+ dependent_targets.each do |target|
428
+ target._add_recursive_dependent_targets(set) if set.add?(target)
429
+ end
430
+
431
+ set
432
+ end
433
+ protected :_add_recursive_dependent_targets
434
+
435
+ # @return [Array<PodTarget>] the recursive targets that this target has a
436
+ # test dependency upon.
437
+ #
438
+ def recursive_test_dependent_targets
439
+ @recursive_test_dependent_targets ||= _add_recursive_test_dependent_targets(Set.new).to_a
440
+ end
441
+
442
+ def _add_recursive_test_dependent_targets(set)
443
+ test_dependent_targets_by_spec_name.each_value do |dependent_targets|
444
+ dependent_targets.each do |target|
445
+ target._add_recursive_dependent_targets(set) if set.add?(target)
446
+ end
447
+ end
448
+
449
+ set
450
+ end
451
+ private :_add_recursive_test_dependent_targets
452
+
453
+ # @return [Array<PodTarget>] the canonical list of dependent targets this target has a dependency upon.
454
+ # This list includes the target itself as well as its recursive dependent and test dependent targets.
455
+ #
456
+ def all_dependent_targets
457
+ [self, *recursive_dependent_targets, *recursive_test_dependent_targets].uniq
458
+ end
459
+
460
+ # Checks if warnings should be inhibited for this pod.
461
+ #
462
+ # @return [Bool]
463
+ #
464
+ def inhibit_warnings?
465
+ return @inhibit_warnings if defined? @inhibit_warnings
466
+ whitelists = target_definitions.map do |target_definition|
467
+ target_definition.inhibits_warnings_for_pod?(root_spec.name)
468
+ end.uniq
469
+
470
+ if whitelists.empty?
471
+ @inhibit_warnings = false
472
+ false
473
+ elsif whitelists.count == 1
474
+ @inhibit_warnings = whitelists.first
475
+ whitelists.first
476
+ else
477
+ UI.warn "The pod `#{pod_name}` is linked to different targets " \
478
+ "(#{target_definitions.map(&:label)}), which contain different " \
479
+ 'settings to inhibit warnings. CocoaPods does not currently ' \
480
+ 'support different settings and will fall back to your preference ' \
481
+ 'set in the root target definition.'
482
+ podfile.root_target_definitions.first.inhibits_warnings_for_pod?(root_spec.name)
483
+ end
484
+ end
485
+
486
+ # @param [String] dir
487
+ # The directory (which might be a variable) relative to which
488
+ # the returned path should be. This must be used if the
489
+ # $CONFIGURATION_BUILD_DIR is modified.
490
+ #
491
+ # @return [String] The absolute path to the configuration build dir
492
+ #
493
+ def configuration_build_dir(dir = BuildSettings::CONFIGURATION_BUILD_DIR_VARIABLE)
494
+ "#{dir}/#{label}"
495
+ end
496
+
497
+ # @param [String] dir
498
+ # @see #configuration_build_dir
499
+ #
500
+ # @return [String] The absolute path to the build product
501
+ #
502
+ def build_product_path(dir = BuildSettings::CONFIGURATION_BUILD_DIR_VARIABLE)
503
+ "#{configuration_build_dir(dir)}/#{product_name}"
504
+ end
505
+
506
+ # @return [String] The source path of the root for this target relative to `$(PODS_ROOT)`
507
+ #
508
+ def pod_target_srcroot
509
+ "${PODS_ROOT}/#{sandbox.pod_dir(pod_name).relative_path_from(sandbox.root)}"
510
+ end
511
+
512
+ # @return [String] The version associated with this target
513
+ #
514
+ def version
515
+ version = root_spec.version
516
+ [version.major, version.minor, version.patch].join('.')
517
+ end
518
+
519
+ # @param [Boolean] include_test_dependent_targets
520
+ # whether to include header search paths for test dependent targets
521
+ #
522
+ # @return [Array<String>] The set of header search paths this target uses.
523
+ #
524
+ def header_search_paths(include_test_dependent_targets = false)
525
+ header_search_paths = []
526
+ header_search_paths.concat(build_headers.search_paths(platform, nil, false))
527
+ header_search_paths.concat(sandbox.public_headers.search_paths(platform, pod_name, uses_modular_headers?))
528
+ dependent_targets = recursive_dependent_targets
529
+ dependent_targets += recursive_test_dependent_targets if include_test_dependent_targets
530
+ dependent_targets.uniq.each do |dependent_target|
531
+ header_search_paths.concat(sandbox.public_headers.search_paths(platform, dependent_target.pod_name, defines_module? && dependent_target.uses_modular_headers?(false)))
532
+ end
533
+ header_search_paths.uniq
534
+ end
535
+
536
+ protected
537
+
538
+ # Returns whether the pod target should use modular headers.
539
+ #
540
+ # @param [Boolean] only_if_defines_modules
541
+ # whether the use of modular headers should require the target to define a module
542
+ #
543
+ # @note This must return false when a pod has a `header_mappings_dir` or `header_dir`,
544
+ # as that allows the spec to customize the header structure, and
545
+ # therefore it might not be expecting the module name to be prepended
546
+ # to imports at all.
547
+ #
548
+ def uses_modular_headers?(only_if_defines_modules = true)
549
+ return false if only_if_defines_modules && !defines_module?
550
+ spec_consumers.none?(&:header_mappings_dir) && spec_consumers.none?(&:header_dir)
551
+ end
552
+
553
+ private
554
+
555
+ def create_build_settings
556
+ BuildSettings::PodTargetSettings.new(self)
557
+ end
558
+ end
559
+ end