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,1075 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pod
4
+ class Target
5
+ # @since 1.5.0
6
+ class BuildSettings
7
+ #-------------------------------------------------------------------------#
8
+
9
+ # @!group Constants
10
+
11
+ # @return [Set<String>]
12
+ # The build settings that should be treated as arrays, rather than strings.
13
+ #
14
+ PLURAL_SETTINGS = %w(
15
+ ALTERNATE_PERMISSIONS_FILES
16
+ ARCHS
17
+ BUILD_VARIANTS
18
+ EXCLUDED_SOURCE_FILE_NAMES
19
+ FRAMEWORK_SEARCH_PATHS
20
+ GCC_PREPROCESSOR_DEFINITIONS
21
+ GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS
22
+ HEADER_SEARCH_PATHS
23
+ INFOPLIST_PREPROCESSOR_DEFINITIONS
24
+ LD_RUNPATH_SEARCH_PATHS
25
+ LIBRARY_SEARCH_PATHS
26
+ OTHER_CFLAGS
27
+ OTHER_CPLUSPLUSFLAGS
28
+ OTHER_LDFLAGS
29
+ OTHER_SWIFT_FLAGS
30
+ REZ_SEARCH_PATHS
31
+ SECTORDER_FLAGS
32
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS
33
+ SWIFT_INCLUDE_PATHS
34
+ WARNING_CFLAGS
35
+ WARNING_LDFLAGS
36
+ ).to_set.freeze
37
+
38
+ # @return [String]
39
+ # The variable for the configuration build directory used when building pod targets.
40
+ #
41
+ CONFIGURATION_BUILD_DIR_VARIABLE = '${PODS_CONFIGURATION_BUILD_DIR}'.freeze
42
+
43
+ #-------------------------------------------------------------------------#
44
+
45
+ # @!group DSL
46
+
47
+ # Creates a method that calculates a part of the build settings for the {#target}.
48
+ #
49
+ # @!visibility private
50
+ #
51
+ # @param [Symbol,String] method_name
52
+ # The name of the method to define
53
+ #
54
+ # @param [Boolean] build_setting
55
+ # Whether the method name should be added (upcased) to {.build_setting_names}
56
+ #
57
+ # @param [Boolean] memoized
58
+ # Whether the method should be memoized
59
+ #
60
+ # @param [Boolean] sorted
61
+ # Whether the return value should be sorted
62
+ #
63
+ # @param [Boolean] uniqued
64
+ # Whether the return value should be uniqued
65
+ #
66
+ # @param [Boolean] compacted
67
+ # Whether the return value should be compacted
68
+ #
69
+ # @param [Boolean] frozen
70
+ # Whether the return value should be frozen
71
+ #
72
+ # @param [Boolean, Symbol] from_search_paths_aggregate_targets
73
+ # If truthy, the method from {Aggregate} that should be used to concatenate build settings from
74
+ # {::Pod::AggregateTarget#search_paths_aggregate_target}
75
+ #
76
+ # @param [Symbol] from_pod_targets_to_link
77
+ # If truthy, the `_to_import` values from `BuildSettings#pod_targets_to_link` will be concatenated
78
+ #
79
+ # @param [Block] implementation
80
+ #
81
+ # @macro [attach] define_build_settings_method
82
+ # @!method $1
83
+ #
84
+ # The `$1` build setting for the {#target}.
85
+ #
86
+ # The return value from this method will be: `${1--1}`.
87
+ #
88
+ def self.define_build_settings_method(method_name, build_setting: false,
89
+ memoized: false, sorted: false, uniqued: false, compacted: false, frozen: true,
90
+ from_search_paths_aggregate_targets: false, from_pod_targets_to_link: false,
91
+ &implementation)
92
+
93
+ memoized_key = "#{self}##{method_name}".freeze
94
+
95
+ (@build_settings_names ||= Set.new) << method_name.to_s.upcase if build_setting
96
+
97
+ raw_method_name = :"_raw_#{method_name}"
98
+ define_method(raw_method_name, &implementation)
99
+ private(raw_method_name)
100
+
101
+ dup_before_freeze = frozen && (from_pod_targets_to_link || from_search_paths_aggregate_targets || uniqued || sorted)
102
+
103
+ define_method(method_name) do
104
+ if memoized
105
+ retval = @__memoized.fetch(memoized_key, :not_found)
106
+ return retval if :not_found != retval
107
+ end
108
+
109
+ retval = send(raw_method_name)
110
+ if retval.nil?
111
+ @__memoized[memoized_key] = retval if memoized
112
+ return
113
+ end
114
+
115
+ retval = retval.dup if dup_before_freeze && retval.frozen?
116
+
117
+ retval.concat(pod_targets_to_link.flat_map { |pod_target| pod_target.build_settings.public_send("#{method_name}_to_import") }) if from_pod_targets_to_link
118
+ retval.concat(search_paths_aggregate_target_pod_target_build_settings.flat_map(&from_search_paths_aggregate_targets)) if from_search_paths_aggregate_targets
119
+
120
+ retval.compact! if compacted
121
+ retval.uniq! if uniqued
122
+ retval.sort! if sorted
123
+ retval.freeze if frozen
124
+
125
+ @__memoized[memoized_key] = retval if memoized
126
+
127
+ retval
128
+ end
129
+ end
130
+ private_class_method :define_build_settings_method
131
+
132
+ class << self
133
+ #-------------------------------------------------------------------------#
134
+
135
+ # @!group Public API
136
+
137
+ # @return [Set<String>] a set of all the build settings names that will
138
+ # be present in the #xcconfig
139
+ #
140
+ attr_reader :build_settings_names
141
+ end
142
+
143
+ #-------------------------------------------------------------------------#
144
+
145
+ # @!group Public API
146
+
147
+ # @return [Target]
148
+ # The target this build settings object is generating build settings for
149
+ #
150
+ attr_reader :target
151
+
152
+ # Initialize a new instance
153
+ #
154
+ # @param [Target] target
155
+ # see {#target}
156
+ #
157
+ def initialize(target)
158
+ @target = target
159
+ @__memoized = {}
160
+ end
161
+
162
+ def initialize_copy(other)
163
+ super
164
+ @__memoized = {}
165
+ end
166
+
167
+ # @return [Xcodeproj::Config]
168
+ define_build_settings_method :xcconfig, :memoized => true do
169
+ settings = add_inherited_to_plural(to_h)
170
+ Xcodeproj::Config.new(settings)
171
+ end
172
+
173
+ alias generate xcconfig
174
+
175
+ # Saves the generated xcconfig to the given path
176
+ #
177
+ # @return [Xcodeproj::Config]
178
+ #
179
+ # @see #xcconfig
180
+ #
181
+ # @param [String,Pathname] path
182
+ # The path the xcconfig will be saved to
183
+ #
184
+ def save_as(path)
185
+ xcconfig.save_as(path)
186
+ end
187
+
188
+ #-------------------------------------------------------------------------#
189
+
190
+ # @!group Paths
191
+
192
+ # @return [String]
193
+ define_build_settings_method :pods_build_dir, :build_setting => true do
194
+ '${BUILD_DIR}'
195
+ end
196
+
197
+ # @return [String]
198
+ define_build_settings_method :pods_configuration_build_dir, :build_setting => true do
199
+ '${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)'
200
+ end
201
+
202
+ #-------------------------------------------------------------------------#
203
+
204
+ # @!group Code Signing
205
+
206
+ # @return [String]
207
+ define_build_settings_method :code_sign_identity, :build_setting => true do
208
+ return unless target.requires_frameworks?
209
+ return unless target.platform.to_sym == :osx
210
+ ''
211
+ end
212
+
213
+ #-------------------------------------------------------------------------#
214
+
215
+ # @!group Frameworks
216
+
217
+ # @return [Array<String>]
218
+ define_build_settings_method :frameworks do
219
+ []
220
+ end
221
+
222
+ # @return [Array<String>]
223
+ define_build_settings_method :weak_frameworks do
224
+ []
225
+ end
226
+
227
+ # @return [Array<String>]
228
+ define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true do
229
+ framework_search_paths_to_import_developer_frameworks(frameworks)
230
+ end
231
+
232
+ # @param [Array<String>] frameworks
233
+ # The list of framework names
234
+ #
235
+ # @return [Array<String>]
236
+ # the `FRAMEWORK_SEARCH_PATHS` needed to import developer frameworks
237
+ def framework_search_paths_to_import_developer_frameworks(frameworks)
238
+ if frameworks.include?('XCTest') || frameworks.include?('SenTestingKit')
239
+ %w[ $(PLATFORM_DIR)/Developer/Library/Frameworks ]
240
+ else
241
+ []
242
+ end
243
+ end
244
+
245
+ #-------------------------------------------------------------------------#
246
+
247
+ # @!group Libraries
248
+
249
+ # @return [Array<String>]
250
+ define_build_settings_method :libraries do
251
+ []
252
+ end
253
+
254
+ #-------------------------------------------------------------------------#
255
+
256
+ # @!group Clang
257
+
258
+ # @return [Array<String>]
259
+ define_build_settings_method :gcc_preprocessor_definitions, :build_setting => true do
260
+ %w( COCOAPODS=1 )
261
+ end
262
+
263
+ # @return [Array<String>]
264
+ define_build_settings_method :other_cflags, :build_setting => true, :memoized => true do
265
+ module_map_files.map { |f| "-fmodule-map-file=#{f}" }
266
+ end
267
+
268
+ # @return [Array<String>]
269
+ define_build_settings_method :module_map_files do
270
+ []
271
+ end
272
+
273
+ #-------------------------------------------------------------------------#
274
+
275
+ # @!group Swift
276
+
277
+ # @return [Boolean]
278
+ # Whether `OTHER_SWIFT_FLAGS` should be generated when the target
279
+ # does not use swift.
280
+ #
281
+ def other_swift_flags_without_swift?
282
+ false
283
+ end
284
+
285
+ # @return [Array<String>]
286
+ define_build_settings_method :other_swift_flags, :build_setting => true, :memoized => true do
287
+ return unless target.uses_swift? || other_swift_flags_without_swift?
288
+ flags = %w(-D COCOAPODS)
289
+ flags.concat module_map_files.flat_map { |f| ['-Xcc', "-fmodule-map-file=#{f}"] }
290
+ flags
291
+ end
292
+
293
+ #-------------------------------------------------------------------------#
294
+
295
+ # @!group Linking
296
+
297
+ # @return [Boolean]
298
+ define_build_settings_method :requires_objc_linker_flag? do
299
+ false
300
+ end
301
+
302
+ # @return [Boolean]
303
+ define_build_settings_method :requires_fobjc_arc? do
304
+ false
305
+ end
306
+
307
+ # @return [Array<String>]
308
+ # the `LD_RUNPATH_SEARCH_PATHS` needed for dynamically linking the {#target}
309
+ #
310
+ # @param [Boolean] requires_host_target
311
+ #
312
+ # @param [Boolean] test_bundle
313
+ #
314
+ def _ld_runpath_search_paths(requires_host_target: false, test_bundle: false)
315
+ if target.platform.symbolic_name == :osx
316
+ ["'@executable_path/../Frameworks'",
317
+ test_bundle ? "'@loader_path/../Frameworks'" : "'@loader_path/Frameworks'"]
318
+ else
319
+ paths = [
320
+ "'@executable_path/Frameworks'",
321
+ "'@loader_path/Frameworks'",
322
+ ]
323
+ paths << "'@executable_path/../../Frameworks'" if requires_host_target
324
+ paths
325
+ end
326
+ end
327
+ private :_ld_runpath_search_paths
328
+
329
+ # @return [Array<String>]
330
+ define_build_settings_method :other_ldflags, :build_setting => true, :memoized => true do
331
+ ld_flags = []
332
+ ld_flags << '-ObjC' if requires_objc_linker_flag?
333
+ if requires_fobjc_arc?
334
+ ld_flags << '-fobjc-arc'
335
+ end
336
+ libraries.each { |l| ld_flags << %(-l"#{l}") }
337
+ frameworks.each { |f| ld_flags << '-framework' << %("#{f}") }
338
+ weak_frameworks.each { |f| ld_flags << '-weak_framework' << %("#{f}") }
339
+ ld_flags
340
+ end
341
+
342
+ #-------------------------------------------------------------------------#
343
+
344
+ # @!group Private Methods
345
+
346
+ private
347
+
348
+ # @return [Hash<String => String|Array<String>>]
349
+ def to_h
350
+ hash = {}
351
+ self.class.build_settings_names.sort.each do |setting|
352
+ hash[setting] = public_send(setting.downcase)
353
+ end
354
+ hash
355
+ end
356
+
357
+ # @return [Hash<String => String>]
358
+ def add_inherited_to_plural(hash)
359
+ Hash[hash.map do |key, value|
360
+ next [key, '$(inherited)'] if value.nil?
361
+ if PLURAL_SETTINGS.include?(key)
362
+ raise ArgumentError, "#{key} is a plural setting, cannot have #{value.inspect} as its value" unless value.is_a? Array
363
+
364
+ value = "$(inherited) #{quote_array(value)}"
365
+ else
366
+ raise ArgumentError, "#{key} is not a plural setting, cannot have #{value.inspect} as its value" unless value.is_a? String
367
+ end
368
+
369
+ [key, value]
370
+ end]
371
+ end
372
+
373
+ # @return [Array<String>]
374
+ #
375
+ # @param [Array<String>] array
376
+ #
377
+ def quote_array(array)
378
+ array.map do |element|
379
+ case element
380
+ when /\A([\w-]+?)=(.+)\z/
381
+ key = Regexp.last_match(1)
382
+ value = Regexp.last_match(2)
383
+ value = %("#{value}") if value =~ /[^\w\d]/
384
+ %(#{key}=#{value})
385
+ when /[\$\[\]\ ]/
386
+ %("#{element}")
387
+ else
388
+ element
389
+ end
390
+ end.join(' ')
391
+ end
392
+
393
+ # @param [Hash] xcconfig_values_by_consumer_by_key
394
+ #
395
+ # @param [#to_s] attribute
396
+ # The name of the attribute being merged
397
+ #
398
+ # @return [Hash<String, String>]
399
+ #
400
+ def merged_xcconfigs(xcconfig_values_by_consumer_by_key, attribute)
401
+ xcconfig_values_by_consumer_by_key.each_with_object({}) do |(key, values_by_consumer), xcconfig|
402
+ uniq_values = values_by_consumer.values.uniq
403
+ values_are_bools = uniq_values.all? { |v| v =~ /\A(yes|no)\z/i }
404
+ if values_are_bools
405
+ # Boolean build settings
406
+ if uniq_values.count > 1
407
+ UI.warn "Can't merge #{attribute} for pod targets: " \
408
+ "#{values_by_consumer.keys.map(&:name)}. Boolean build " \
409
+ "setting #{key} has different values."
410
+ else
411
+ xcconfig[key] = uniq_values.first
412
+ end
413
+ elsif PLURAL_SETTINGS.include? key
414
+ # Plural build settings
415
+ xcconfig[key] = uniq_values.join(' ')
416
+ elsif uniq_values.count > 1
417
+ # Singular build settings
418
+ UI.warn "Can't merge #{attribute} for pod targets: " \
419
+ "#{values_by_consumer.keys.map(&:name)}. Singular build " \
420
+ "setting #{key} has different values."
421
+ else
422
+ xcconfig[key] = uniq_values.first
423
+ end
424
+ end
425
+ end
426
+
427
+ # Filters out pod targets whose `specs` are a subset of
428
+ # another target's.
429
+ #
430
+ # @param [Array<PodTarget>] pod_targets
431
+ #
432
+ # @return [Array<PodTarget>]
433
+ #
434
+ def select_maximal_pod_targets(pod_targets)
435
+ subset_targets = []
436
+ pod_targets.uniq.combination(2) do |a, b|
437
+ if (a.specs - b.specs).empty?
438
+ subset_targets << a
439
+ elsif (b.specs - a.specs).empty?
440
+ subset_targets << b
441
+ end
442
+ end
443
+ pod_targets - subset_targets
444
+ end
445
+
446
+ # A subclass that generates build settings for a {PodTarget}
447
+ class PodTargetSettings < BuildSettings
448
+ #-------------------------------------------------------------------------#
449
+
450
+ # @!group Public API
451
+
452
+ # @see BuildSettings.build_settings_names
453
+ def self.build_settings_names
454
+ @build_settings_names | BuildSettings.build_settings_names
455
+ end
456
+
457
+ # @return [Boolean]
458
+ # whether settings are being generated for a test bundle
459
+ #
460
+ attr_reader :test_xcconfig
461
+ alias test_xcconfig? test_xcconfig
462
+
463
+ # @return [Specification]
464
+ # The test specification these build settings are for or `nil`.
465
+ #
466
+ attr_reader :test_spec
467
+
468
+ # Initializes a new instance
469
+ #
470
+ # @param [PodTarget] target
471
+ # see {#target}
472
+ #
473
+ # @param [Specification] test_spec
474
+ # see {#test_spec}
475
+ #
476
+ def initialize(target, test_spec = nil)
477
+ super(target)
478
+ @test_spec = test_spec
479
+ @test_xcconfig = !test_spec.nil?
480
+ end
481
+
482
+ # @return [Xcodeproj::Xconfig]
483
+ define_build_settings_method :xcconfig, :memoized => true do
484
+ xcconfig = super()
485
+ xcconfig.merge(merged_pod_target_xcconfigs)
486
+ end
487
+
488
+ #-------------------------------------------------------------------------#
489
+
490
+ # @!group Paths
491
+
492
+ # @return [String]
493
+ define_build_settings_method :pods_root, :build_setting => true do
494
+ '${SRCROOT}'
495
+ end
496
+
497
+ # @return [String]
498
+ define_build_settings_method :pods_target_srcroot, :build_setting => true do
499
+ target.pod_target_srcroot
500
+ end
501
+
502
+ #-------------------------------------------------------------------------#
503
+
504
+ # @!group Frameworks
505
+
506
+ # @return [Array<String>]
507
+ define_build_settings_method :consumer_frameworks, :memoized => true do
508
+ spec_consumers.flat_map(&:frameworks)
509
+ end
510
+
511
+ # @return [Array<String>]
512
+ define_build_settings_method :frameworks, :memoized => true, :sorted => true, :uniqued => true do
513
+ return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
514
+
515
+ frameworks = vendored_dynamic_frameworks.map { |l| File.basename(l, '.framework') }
516
+ frameworks.concat vendored_static_frameworks.map { |l| File.basename(l, '.framework') } unless test_xcconfig?
517
+ frameworks.concat consumer_frameworks
518
+ frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.dynamic_frameworks_to_import }
519
+ frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.static_frameworks_to_import } if test_xcconfig?
520
+ frameworks
521
+ end
522
+
523
+ # @return [Array<String>]
524
+ define_build_settings_method :static_frameworks_to_import, :memoized => true do
525
+ static_frameworks_to_import = []
526
+ static_frameworks_to_import.concat vendored_static_frameworks.map { |f| File.basename(f, '.framework') } unless target.should_build? && target.requires_frameworks? && !target.static_framework?
527
+ static_frameworks_to_import << target.product_basename if target.should_build? && target.requires_frameworks? && target.static_framework?
528
+ static_frameworks_to_import
529
+ end
530
+
531
+ # @return [Array<String>]
532
+ define_build_settings_method :dynamic_frameworks_to_import, :memoized => true do
533
+ dynamic_frameworks_to_import = vendored_dynamic_frameworks.map { |f| File.basename(f, '.framework') }
534
+ dynamic_frameworks_to_import << target.product_basename if target.should_build? && target.requires_frameworks? && !target.static_framework?
535
+ dynamic_frameworks_to_import.concat consumer_frameworks
536
+ dynamic_frameworks_to_import
537
+ end
538
+
539
+ # @return [Array<String>]
540
+ define_build_settings_method :weak_frameworks, :memoized => true do
541
+ return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
542
+
543
+ weak_frameworks = spec_consumers.flat_map(&:weak_frameworks)
544
+ weak_frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.weak_frameworks_to_import }
545
+ weak_frameworks
546
+ end
547
+
548
+ # @return [Array<String>]
549
+ define_build_settings_method :frameworks_to_import, :memoized => true, :sorted => true, :uniqued => true do
550
+ static_frameworks_to_import + dynamic_frameworks_to_import
551
+ end
552
+
553
+ # @return [Array<String>]
554
+ define_build_settings_method :weak_frameworks_to_import, :memoized => true, :sorted => true, :uniqued => true do
555
+ []
556
+ end
557
+
558
+ # @return [Array<String>]
559
+ define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
560
+ paths = super().dup
561
+ paths.concat dependent_targets.flat_map { |t| t.build_settings.framework_search_paths_to_import }
562
+ paths.concat framework_search_paths_to_import
563
+ paths.delete(target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)) unless test_xcconfig?
564
+ paths
565
+ end
566
+
567
+ # @return [Array<String>]
568
+ define_build_settings_method :vendored_framework_search_paths, :memoized => true do
569
+ file_accessors.flat_map(&:vendored_frameworks).map { |f| File.join '${PODS_ROOT}', f.dirname.relative_path_from(target.sandbox.root) }
570
+ end
571
+
572
+ # @return [Array<String>]
573
+ define_build_settings_method :framework_search_paths_to_import, :memoized => true do
574
+ paths = framework_search_paths_to_import_developer_frameworks(consumer_frameworks)
575
+ paths.concat vendored_framework_search_paths
576
+ return paths unless target.requires_frameworks? && target.should_build?
577
+
578
+ paths + [target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)]
579
+ end
580
+
581
+ # @return [Array<String>]
582
+ define_build_settings_method :vendored_static_frameworks, :memoized => true do
583
+ file_accessors.flat_map(&:vendored_static_frameworks)
584
+ end
585
+
586
+ # @return [Array<String>]
587
+ define_build_settings_method :vendored_dynamic_frameworks, :memoized => true do
588
+ file_accessors.flat_map(&:vendored_dynamic_frameworks)
589
+ end
590
+
591
+ #-------------------------------------------------------------------------#
592
+
593
+ # @!group Libraries
594
+
595
+ # @return [Array<String>]
596
+ define_build_settings_method :libraries, :memoized => true, :sorted => true, :uniqued => true do
597
+ return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
598
+
599
+ libraries = libraries_to_import.dup
600
+ libraries.concat dependent_targets.flat_map { |pt| pt.build_settings.dynamic_libraries_to_import }
601
+ libraries.concat dependent_targets.flat_map { |pt| pt.build_settings.static_libraries_to_import } if test_xcconfig?
602
+ libraries
603
+ end
604
+
605
+ # @return [Array<String>]
606
+ define_build_settings_method :static_libraries_to_import, :memoized => true do
607
+ static_libraries_to_import = vendored_static_libraries.map { |l| File.basename(l, l.extname).sub(/\Alib/, '') }
608
+ static_libraries_to_import << target.product_basename if target.should_build? && !target.requires_frameworks?
609
+ static_libraries_to_import
610
+ end
611
+
612
+ # @return [Array<String>]
613
+ define_build_settings_method :dynamic_libraries_to_import, :memoized => true do
614
+ vendored_dynamic_libraries.map { |l| File.basename(l, l.extname).sub(/\Alib/, '') } +
615
+ spec_consumers.flat_map(&:libraries)
616
+ end
617
+
618
+ # @return [Array<String>]
619
+ define_build_settings_method :libraries_to_import, :memoized => true, :sorted => true, :uniqued => true do
620
+ static_libraries_to_import + dynamic_libraries_to_import
621
+ end
622
+
623
+ # @return [Array<String>]
624
+ define_build_settings_method :library_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
625
+ return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
626
+
627
+ vendored = library_search_paths_to_import.dup
628
+ vendored.concat dependent_targets.flat_map { |t| t.build_settings.vendored_dynamic_library_search_paths }
629
+ if test_xcconfig?
630
+ vendored.concat dependent_targets.flat_map { |t| t.build_settings.library_search_paths_to_import }
631
+ else
632
+ vendored.delete(target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE))
633
+ end
634
+ vendored
635
+ end
636
+
637
+ # @return [Array<String>]
638
+ define_build_settings_method :vendored_static_libraries, :memoized => true do
639
+ file_accessors.flat_map(&:vendored_static_libraries)
640
+ end
641
+
642
+ # @return [Array<String>]
643
+ define_build_settings_method :vendored_dynamic_libraries, :memoized => true do
644
+ file_accessors.flat_map(&:vendored_dynamic_libraries)
645
+ end
646
+
647
+ # @return [Array<String>]
648
+ define_build_settings_method :vendored_static_library_search_paths, :memoized => true do
649
+ vendored_static_libraries.map { |f| File.join '${PODS_ROOT}', f.dirname.relative_path_from(target.sandbox.root) }
650
+ end
651
+
652
+ # @return [Array<String>]
653
+ define_build_settings_method :vendored_dynamic_library_search_paths, :memoized => true do
654
+ vendored_dynamic_libraries.map { |f| File.join '${PODS_ROOT}', f.dirname.relative_path_from(target.sandbox.root) }
655
+ end
656
+
657
+ # @return [Array<String>]
658
+ define_build_settings_method :library_search_paths_to_import, :memoized => true do
659
+ vendored_library_search_paths = vendored_static_library_search_paths + vendored_dynamic_library_search_paths
660
+ return vendored_library_search_paths if target.requires_frameworks? || !target.should_build?
661
+
662
+ vendored_library_search_paths << target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
663
+ end
664
+
665
+ #-------------------------------------------------------------------------#
666
+
667
+ # @!group Clang
668
+
669
+ # @return [Array<String>]
670
+ define_build_settings_method :module_map_files, :memoized => true do
671
+ dependent_targets.map { |t| t.build_settings.module_map_file_to_import }.compact.sort
672
+ end
673
+
674
+ # @return [Array<String>]
675
+ define_build_settings_method :module_map_file_to_import, :memoized => true do
676
+ return unless target.should_build?
677
+ return if target.requires_frameworks?
678
+ return unless target.defines_module?
679
+
680
+ if target.uses_swift?
681
+ # for swift, we have a custom build phase that copies in the module map, appending the .Swift module
682
+ "${PODS_CONFIGURATION_BUILD_DIR}/#{target.label}/#{target.product_module_name}.modulemap"
683
+ else
684
+ "${PODS_ROOT}/#{target.module_map_path.relative_path_from(target.sandbox.root)}"
685
+ end
686
+ end
687
+
688
+ # @return [Array<String>]
689
+ define_build_settings_method :header_search_paths, :build_setting => true, :memoized => true, :sorted => true do
690
+ target.header_search_paths(test_xcconfig?)
691
+ end
692
+
693
+ #-------------------------------------------------------------------------#
694
+
695
+ # @!group Swift
696
+
697
+ # @return [Array<String>]
698
+ define_build_settings_method :other_swift_flags, :build_setting => true, :memoized => true do
699
+ return unless target.uses_swift?
700
+ flags = super()
701
+ flags << '-suppress-warnings' if target.inhibit_warnings?
702
+ if !target.requires_frameworks? && target.defines_module? && !test_xcconfig?
703
+ flags.concat %w( -import-underlying-module -Xcc -fmodule-map-file=${SRCROOT}/${MODULEMAP_FILE} )
704
+ end
705
+ flags
706
+ end
707
+
708
+ # @return [Array<String>]
709
+ define_build_settings_method :swift_include_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
710
+ paths = dependent_targets.flat_map { |t| t.build_settings.swift_include_paths_to_import }
711
+ paths.concat swift_include_paths_to_import if test_xcconfig?
712
+ paths
713
+ end
714
+
715
+ # @return [Array<String>]
716
+ define_build_settings_method :swift_include_paths_to_import, :memoized => true do
717
+ return [] unless target.uses_swift? && !target.requires_frameworks?
718
+
719
+ [target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)]
720
+ end
721
+
722
+ #-------------------------------------------------------------------------#
723
+
724
+ # @!group Linking
725
+
726
+ # @return [Boolean] whether the `-ObjC` linker flag is required.
727
+ #
728
+ # @note this is only true when generating build settings for a test bundle
729
+ #
730
+ def requires_objc_linker_flag?
731
+ test_xcconfig?
732
+ end
733
+
734
+ # @return [Boolean] whether the `-fobjc-arc` linker flag is required.
735
+ #
736
+ define_build_settings_method :requires_fobjc_arc?, :memoized => true do
737
+ target.podfile.set_arc_compatibility_flag? &&
738
+ file_accessors.any? { |fa| fa.spec_consumer.requires_arc? }
739
+ end
740
+
741
+ # @return [Array<String>]
742
+ define_build_settings_method :ld_runpath_search_paths, :build_setting => true, :memoized => true do
743
+ return unless test_xcconfig?
744
+ _ld_runpath_search_paths(:test_bundle => true)
745
+ end
746
+
747
+ #-------------------------------------------------------------------------#
748
+
749
+ # @!group Packaging
750
+
751
+ # @return [String]
752
+ define_build_settings_method :skip_install, :build_setting => true do
753
+ 'YES'
754
+ end
755
+
756
+ # @return [String]
757
+ define_build_settings_method :product_bundle_identifier, :build_setting => true do
758
+ 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
759
+ end
760
+
761
+ # @return [String]
762
+ define_build_settings_method :configuration_build_dir, :build_setting => true, :memoized => true do
763
+ return if test_xcconfig?
764
+ target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
765
+ end
766
+
767
+ #-------------------------------------------------------------------------#
768
+
769
+ # @!group Target Properties
770
+
771
+ # @return [Array<PodTarget>]
772
+ define_build_settings_method :dependent_targets, :memoized => true do
773
+ select_maximal_pod_targets(
774
+ if test_xcconfig?
775
+ target.all_dependent_targets
776
+ else
777
+ target.recursive_dependent_targets
778
+ end,
779
+ )
780
+ end
781
+
782
+ # Returns the +pod_target_xcconfig+ for the pod target and its spec
783
+ # consumers grouped by keys
784
+ #
785
+ # @return [Hash{String,Hash{Target,String}]
786
+ #
787
+ def pod_target_xcconfig_values_by_consumer_by_key
788
+ spec_consumers.each_with_object({}) do |spec_consumer, hash|
789
+ spec_consumer.pod_target_xcconfig.each do |k, v|
790
+ (hash[k] ||= {})[spec_consumer] = v
791
+ end
792
+ end
793
+ end
794
+
795
+ # Merges the +pod_target_xcconfig+ for all pod targets into a
796
+ # single hash and warns on conflicting definitions.
797
+ #
798
+ # @return [Hash{String, String}]
799
+ #
800
+ define_build_settings_method :merged_pod_target_xcconfigs, :memoized => true do
801
+ merged_xcconfigs(pod_target_xcconfig_values_by_consumer_by_key, :pod_target_xcconfig)
802
+ end
803
+
804
+ # @return [Array<Sandbox::FileAccessor>]
805
+ define_build_settings_method :file_accessors, :memoized => true do
806
+ target.file_accessors.select { |fa| fa.spec.test_specification? == test_xcconfig? }
807
+ end
808
+
809
+ # @return [Array<Specification::Consumer>]
810
+ define_build_settings_method :spec_consumers, :memoized => true do
811
+ target.spec_consumers.select { |c| c.spec.test_specification? == test_xcconfig? }
812
+ end
813
+
814
+ #-------------------------------------------------------------------------#
815
+ end
816
+
817
+ # A subclass that generates build settings for a `PodTarget`
818
+ class AggregateTargetSettings < BuildSettings
819
+ #-------------------------------------------------------------------------#
820
+
821
+ # @!group Public API
822
+
823
+ # @see BuildSettings.build_settings_names
824
+ def self.build_settings_names
825
+ @build_settings_names | BuildSettings.build_settings_names
826
+ end
827
+
828
+ # @return [String]
829
+ # The build configuration these settings will be used for
830
+ attr_reader :configuration_name
831
+
832
+ # Intializes a new instance
833
+ #
834
+ # @param [AggregateTarget] target
835
+ # see {#target}
836
+ #
837
+ # @param [String] configuration_name
838
+ # see {#configuration_name}
839
+ #
840
+ def initialize(target, configuration_name)
841
+ super(target)
842
+ @configuration_name = configuration_name
843
+ end
844
+
845
+ # @return [Xcodeproj::Config] xcconfig
846
+ define_build_settings_method :xcconfig, :memoized => true do
847
+ xcconfig = super()
848
+ xcconfig.merge(merged_user_target_xcconfigs)
849
+ end
850
+
851
+ #-------------------------------------------------------------------------#
852
+
853
+ # @!group Paths
854
+
855
+ # @return [String]
856
+ define_build_settings_method :pods_podfile_dir_path, :build_setting => true, :memoized => true do
857
+ target.podfile_dir_relative_path
858
+ end
859
+
860
+ # @return [String]
861
+ define_build_settings_method :pods_root, :build_setting => true, :memoized => true do
862
+ target.relative_pods_root
863
+ end
864
+
865
+ #-------------------------------------------------------------------------#
866
+
867
+ # @!group Frameworks
868
+
869
+ # @return [Array<String>]
870
+ define_build_settings_method :frameworks, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :dynamic_frameworks_to_import do
871
+ []
872
+ end
873
+
874
+ # @return [Array<String>]
875
+ define_build_settings_method :weak_frameworks, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :weak_frameworks do
876
+ []
877
+ end
878
+
879
+ # @return [Array<String>]
880
+ define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :framework_search_paths_to_import do
881
+ []
882
+ end
883
+
884
+ #-------------------------------------------------------------------------#
885
+
886
+ # @!group Libraries
887
+
888
+ # @return [Array<String>]
889
+ define_build_settings_method :libraries, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :dynamic_libraries_to_import do
890
+ []
891
+ end
892
+
893
+ # @return [Array<String>]
894
+ define_build_settings_method :library_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :vendored_dynamic_library_search_paths do
895
+ []
896
+ end
897
+
898
+ #-------------------------------------------------------------------------#
899
+
900
+ # @!group Clang
901
+
902
+ # @return [Array<String>]
903
+ define_build_settings_method :header_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
904
+ paths = []
905
+
906
+ if !target.requires_frameworks? || !pod_targets.all?(&:should_build?)
907
+ paths.concat target.sandbox.public_headers.search_paths(target.platform)
908
+ end
909
+
910
+ paths.concat target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).header_search_paths }
911
+
912
+ paths
913
+ end
914
+
915
+ # @return [Array<String>]
916
+ define_build_settings_method :other_cflags, :build_setting => true, :memoized => true do
917
+ flags = super()
918
+ flags +
919
+ header_search_paths.flat_map { |p| ['-isystem', p] } +
920
+ framework_header_paths_for_iquote.flat_map { |p| ['-iquote', p] }
921
+ end
922
+
923
+ # @return [Array<String>]
924
+ define_build_settings_method :framework_header_paths_for_iquote, :memoized => true, :sorted => true, :uniqued => true do
925
+ paths = pod_targets.
926
+ select { |pt| pt.should_build? && pt.requires_frameworks? }.
927
+ map { |pt| "#{pt.build_product_path}/Headers" }
928
+ paths.concat target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).framework_header_paths_for_iquote }
929
+ paths
930
+ end
931
+
932
+ # @return [Array<String>]
933
+ define_build_settings_method :module_map_files, :memoized => true, :sorted => true, :uniqued => true, :compacted => true, :from_search_paths_aggregate_targets => :module_map_file_to_import do
934
+ pod_targets.map { |t| t.build_settings.module_map_file_to_import }
935
+ end
936
+
937
+ #-------------------------------------------------------------------------#
938
+
939
+ # @!group Swift
940
+
941
+ # @see BuildSettings#other_swift_flags_without_swift?
942
+ def other_swift_flags_without_swift?
943
+ module_map_files.any?
944
+ end
945
+
946
+ # @return [Array<String>]
947
+ define_build_settings_method :swift_include_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true, :from_pod_targets_to_link => true, :from_search_paths_aggregate_targets => :swift_include_paths_to_import do
948
+ []
949
+ end
950
+
951
+ # @return [String]
952
+ define_build_settings_method :always_embed_swift_standard_libraries, :build_setting => true, :memoized => true do
953
+ return unless must_embed_swift?
954
+ return if target_swift_version < EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
955
+
956
+ 'YES'
957
+ end
958
+
959
+ # @return [String]
960
+ define_build_settings_method :embedded_content_contains_swift, :build_setting => true, :memoized => true do
961
+ return unless must_embed_swift?
962
+ return if target_swift_version >= EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
963
+
964
+ 'YES'
965
+ end
966
+
967
+ # @return [Boolean]
968
+ define_build_settings_method :must_embed_swift?, :memoized => true do
969
+ !target.requires_host_target? && pod_targets.any?(&:uses_swift?)
970
+ end
971
+
972
+ #-------------------------------------------------------------------------#
973
+
974
+ # @!group Linking
975
+
976
+ # @return [Array<String>]
977
+ define_build_settings_method :ld_runpath_search_paths, :build_setting => true, :memoized => true, :uniqued => true do
978
+ return unless target.requires_frameworks? || any_vendored_dynamic_artifacts?
979
+ symbol_type = target.user_targets.map(&:symbol_type).uniq.first
980
+ test_bundle = symbol_type == :octest_bundle || symbol_type == :unit_test_bundle || symbol_type == :ui_test_bundle
981
+ _ld_runpath_search_paths(:requires_host_target => target.requires_host_target?, :test_bundle => test_bundle)
982
+ end
983
+
984
+ # @return [Boolean]
985
+ define_build_settings_method :any_vendored_dynamic_artifacts?, :memoized => true do
986
+ pod_targets.any? do |pt|
987
+ pt.file_accessors.any? do |fa|
988
+ fa.vendored_dynamic_artifacts.any?
989
+ end
990
+ end
991
+ end
992
+
993
+ # @return [Boolean]
994
+ define_build_settings_method :requires_objc_linker_flag?, :memoized => true do
995
+ includes_static_libs = !target.requires_frameworks?
996
+ includes_static_libs || pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_static_artifacts.empty? }
997
+ end
998
+
999
+ # @return [Boolean]
1000
+ define_build_settings_method :requires_fobjc_arc?, :memoized => true do
1001
+ target.podfile.set_arc_compatibility_flag? &&
1002
+ target.spec_consumers.any?(&:requires_arc?)
1003
+ end
1004
+
1005
+ #-------------------------------------------------------------------------#
1006
+
1007
+ # @!group Target Properties
1008
+
1009
+ # @return [Version] the SWIFT_VERSION of the target being integrated
1010
+ #
1011
+ define_build_settings_method :target_swift_version, :memoized => true, :frozen => false do
1012
+ swift_version = target.target_definition.swift_version
1013
+ swift_version = nil if swift_version.blank?
1014
+ Version.new(swift_version)
1015
+ end
1016
+
1017
+ EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION = Version.new('2.3')
1018
+ private_constant :EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
1019
+
1020
+ # Returns the {PodTarget}s which are active for the current
1021
+ # configuration name.
1022
+ #
1023
+ # @return [Array<PodTarget>]
1024
+ #
1025
+ define_build_settings_method :pod_targets, :memoized => true do
1026
+ target.pod_targets_for_build_configuration(configuration_name)
1027
+ end
1028
+
1029
+ # @return [Array<PodTarget>]
1030
+ define_build_settings_method :pod_targets_to_link, :memoized => true do
1031
+ pod_targets -
1032
+ target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).pod_targets_to_link }
1033
+ end
1034
+
1035
+ # @return [Array<PodTarget>]
1036
+ define_build_settings_method :search_paths_aggregate_target_pod_target_build_settings, :memoized => true, :uniqued => true do
1037
+ pod_targets = target.search_paths_aggregate_targets.flat_map { |at| at.build_settings(configuration_name).pod_targets }
1038
+ pod_targets = select_maximal_pod_targets(pod_targets)
1039
+ pod_targets.flat_map(&:build_settings)
1040
+ end
1041
+
1042
+ # Returns the +user_target_xcconfig+ for all pod targets and their spec
1043
+ # consumers grouped by keys
1044
+ #
1045
+ # @return [Hash{String,Hash{Target,String}]
1046
+ #
1047
+ def user_target_xcconfig_values_by_consumer_by_key
1048
+ pod_targets.each_with_object({}) do |target, hash|
1049
+ target.spec_consumers.each do |spec_consumer|
1050
+ spec_consumer.user_target_xcconfig.each do |k, v|
1051
+ # TODO: Need to decide how we are going to ensure settings like these
1052
+ # are always excluded from the user's project.
1053
+ #
1054
+ # See https://github.com/CocoaPods/CocoaPods/issues/1216
1055
+ next if k == 'USE_HEADERMAP'
1056
+ (hash[k] ||= {})[spec_consumer] = v
1057
+ end
1058
+ end
1059
+ end
1060
+ end
1061
+
1062
+ # Merges the +user_target_xcconfig+ for all pod targets into a
1063
+ # single hash and warns on conflicting definitions.
1064
+ #
1065
+ # @return [Hash{String, String}]
1066
+ #
1067
+ define_build_settings_method :merged_user_target_xcconfigs, :memoized => true do
1068
+ merged_xcconfigs(user_target_xcconfig_values_by_consumer_by_key, :user_target_xcconfig)
1069
+ end
1070
+
1071
+ #-------------------------------------------------------------------------#
1072
+ end
1073
+ end
1074
+ end
1075
+ end