cocoapods 1.5.2 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +365 -1
  3. data/bin/pod +1 -1
  4. data/lib/cocoapods/command/cache/clean.rb +1 -1
  5. data/lib/cocoapods/command/init.rb +4 -2
  6. data/lib/cocoapods/command/install.rb +7 -0
  7. data/lib/cocoapods/command/lib/lint.rb +8 -1
  8. data/lib/cocoapods/command/outdated.rb +4 -9
  9. data/lib/cocoapods/command/repo/add.rb +1 -1
  10. data/lib/cocoapods/command/repo/list.rb +1 -1
  11. data/lib/cocoapods/command/repo/push.rb +17 -12
  12. data/lib/cocoapods/command/repo/remove.rb +1 -1
  13. data/lib/cocoapods/command/repo/update.rb +1 -1
  14. data/lib/cocoapods/command/setup.rb +1 -1
  15. data/lib/cocoapods/command/spec/create.rb +39 -39
  16. data/lib/cocoapods/command/spec/lint.rb +8 -1
  17. data/lib/cocoapods/command.rb +3 -1
  18. data/lib/cocoapods/config.rb +13 -2
  19. data/lib/cocoapods/downloader/cache.rb +1 -1
  20. data/lib/cocoapods/executable.rb +3 -3
  21. data/lib/cocoapods/external_sources/abstract_external_source.rb +23 -13
  22. data/lib/cocoapods/external_sources.rb +7 -4
  23. data/lib/cocoapods/gem_version.rb +1 -1
  24. data/lib/cocoapods/generator/acknowledgements/markdown.rb +6 -0
  25. data/lib/cocoapods/generator/acknowledgements/plist.rb +13 -2
  26. data/lib/cocoapods/generator/app_target_helper.rb +141 -17
  27. data/lib/cocoapods/generator/copy_resources_script.rb +14 -3
  28. data/lib/cocoapods/generator/dummy_source.rb +14 -5
  29. data/lib/cocoapods/generator/embed_frameworks_script.rb +37 -20
  30. data/lib/cocoapods/generator/header.rb +1 -1
  31. data/lib/cocoapods/generator/info_plist_file.rb +12 -4
  32. data/lib/cocoapods/generator/prefix_header.rb +2 -2
  33. data/lib/cocoapods/hooks_manager.rb +28 -17
  34. data/lib/cocoapods/installer/analyzer/analysis_result.rb +52 -22
  35. data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +14 -6
  36. data/lib/cocoapods/installer/analyzer/pod_variant.rb +4 -5
  37. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +3 -14
  38. data/lib/cocoapods/installer/analyzer/specs_state.rb +28 -4
  39. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +27 -14
  40. data/lib/cocoapods/installer/analyzer/target_inspector.rb +17 -11
  41. data/lib/cocoapods/installer/analyzer.rb +391 -284
  42. data/lib/cocoapods/installer/installation_options.rb +2 -0
  43. data/lib/cocoapods/installer/pod_source_installer.rb +31 -43
  44. data/lib/cocoapods/installer/post_install_hooks_context.rb +72 -47
  45. data/lib/cocoapods/installer/pre_install_hooks_context.rb +22 -13
  46. data/lib/cocoapods/installer/source_provider_hooks_context.rb +3 -1
  47. data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +44 -11
  48. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +69 -29
  49. data/lib/cocoapods/installer/user_project_integrator.rb +6 -4
  50. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +25 -16
  51. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +104 -0
  52. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +23 -50
  53. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +296 -177
  54. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +51 -33
  55. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +93 -0
  56. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +62 -69
  57. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +72 -0
  58. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +130 -122
  59. data/lib/cocoapods/installer/xcode/target_validator.rb +15 -9
  60. data/lib/cocoapods/installer.rb +140 -63
  61. data/lib/cocoapods/project.rb +16 -14
  62. data/lib/cocoapods/resolver/resolver_specification.rb +41 -0
  63. data/lib/cocoapods/resolver.rb +79 -98
  64. data/lib/cocoapods/sandbox/file_accessor.rb +11 -6
  65. data/lib/cocoapods/sandbox/headers_store.rb +9 -8
  66. data/lib/cocoapods/sandbox/path_list.rb +5 -8
  67. data/lib/cocoapods/sandbox.rb +31 -43
  68. data/lib/cocoapods/sources_manager.rb +1 -1
  69. data/lib/cocoapods/target/aggregate_target.rb +143 -85
  70. data/lib/cocoapods/target/build_settings.rb +1124 -0
  71. data/lib/cocoapods/target/framework_paths.rb +36 -0
  72. data/lib/cocoapods/target/pod_target.rb +198 -295
  73. data/lib/cocoapods/target.rb +92 -37
  74. data/lib/cocoapods/user_interface.rb +5 -0
  75. data/lib/cocoapods/validator.rb +149 -44
  76. data/lib/cocoapods.rb +0 -1
  77. metadata +31 -23
  78. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +0 -260
  79. data/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb +0 -87
  80. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +0 -558
  81. data/lib/cocoapods/generator/xcconfig.rb +0 -13
@@ -4,12 +4,18 @@ module Pod
4
4
  # The {PodsProjectGenerator} handles generation of the 'Pods/Pods.xcodeproj'
5
5
  #
6
6
  class PodsProjectGenerator
7
+ require 'cocoapods/installer/xcode/pods_project_generator/target_installer_helper'
7
8
  require 'cocoapods/installer/xcode/pods_project_generator/pod_target_integrator'
8
9
  require 'cocoapods/installer/xcode/pods_project_generator/target_installer'
10
+ require 'cocoapods/installer/xcode/pods_project_generator/target_installation_result'
9
11
  require 'cocoapods/installer/xcode/pods_project_generator/pod_target_installer'
10
12
  require 'cocoapods/installer/xcode/pods_project_generator/file_references_installer'
11
13
  require 'cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer'
12
14
 
15
+ # @return [Sandbox] The sandbox where the Pods should be installed.
16
+ #
17
+ attr_reader :sandbox
18
+
13
19
  # @return [Pod::Project] the `Pods/Pods.xcodeproj` project.
14
20
  #
15
21
  attr_reader :project
@@ -20,10 +26,6 @@ module Pod
20
26
  #
21
27
  attr_reader :aggregate_targets
22
28
 
23
- # @return [Sandbox] The sandbox where the Pods should be installed.
24
- #
25
- attr_reader :sandbox
26
-
27
29
  # @return [Array<PodTarget>] The model representations of pod targets.
28
30
  #
29
31
  attr_reader :pod_targets
@@ -43,16 +45,16 @@ module Pod
43
45
 
44
46
  # Initialize a new instance
45
47
  #
46
- # @param [Array<AggregateTarget>] aggregate_targets @see aggregate_targets
47
- # @param [Sandbox] sandbox @see sandbox
48
- # @param [Array<PodTarget>] pod_targets @see pod_targets
49
- # @param [Analyzer] analysis_result @see analysis_result
50
- # @param [InstallationOptions] installation_options @see installation_options
51
- # @param [Config] config @see config
48
+ # @param [Sandbox] sandbox @see #sandbox
49
+ # @param [Array<AggregateTarget>] aggregate_targets @see #aggregate_targets
50
+ # @param [Array<PodTarget>] pod_targets @see #pod_targets
51
+ # @param [Analyzer] analysis_result @see #analysis_result
52
+ # @param [InstallationOptions] installation_options @see #installation_options
53
+ # @param [Config] config @see #config
52
54
  #
53
- def initialize(aggregate_targets, sandbox, pod_targets, analysis_result, installation_options, config)
54
- @aggregate_targets = aggregate_targets
55
+ def initialize(sandbox, aggregate_targets, pod_targets, analysis_result, installation_options, config)
55
56
  @sandbox = sandbox
57
+ @aggregate_targets = aggregate_targets
56
58
  @pod_targets = pod_targets
57
59
  @analysis_result = analysis_result
58
60
  @installation_options = installation_options
@@ -62,9 +64,10 @@ module Pod
62
64
  def generate!
63
65
  prepare
64
66
  install_file_references
65
- install_libraries
66
- integrate_targets
67
- set_target_dependencies
67
+ @target_installation_results = install_targets
68
+ integrate_targets(@target_installation_results.pod_target_installation_results)
69
+ wire_target_dependencies(@target_installation_results)
70
+ @target_installation_results
68
71
  end
69
72
 
70
73
  def write
@@ -76,11 +79,19 @@ module Pod
76
79
  UI.message('- Generating deterministic UUIDs') { project.predictabilize_uuids }
77
80
  end
78
81
  library_product_types = [:framework, :dynamic_library, :static_library]
82
+
83
+ pod_target_installation_results = @target_installation_results.pod_target_installation_results
84
+ results_by_native_target = Hash[pod_target_installation_results.map do |_, result|
85
+ [result.native_target, result]
86
+ end]
79
87
  project.recreate_user_schemes(false) do |scheme, target|
88
+ next unless target.respond_to?(:symbol_type)
80
89
  next unless library_product_types.include? target.symbol_type
81
- pod_target = pod_targets.find { |pt| pt.native_target == target }
82
- next if pod_target.nil? || pod_target.test_native_targets.empty?
83
- pod_target.test_native_targets.each { |test_native_target| scheme.add_test_target(test_native_target) }
90
+ installation_result = results_by_native_target[target]
91
+ next unless installation_result
92
+ installation_result.test_native_targets.each do |test_native_target|
93
+ scheme.add_test_target(test_native_target)
94
+ end
84
95
  end
85
96
  project.save
86
97
  end
@@ -95,8 +106,8 @@ module Pod
95
106
  next unless share_scheme_for_development_pod?(pod_target.pod_name)
96
107
  Xcodeproj::XCScheme.share_scheme(project.path, pod_target.label)
97
108
  if pod_target.contains_test_specifications?
98
- pod_target.supported_test_types.each do |test_type|
99
- Xcodeproj::XCScheme.share_scheme(project.path, pod_target.test_target_label(test_type))
109
+ pod_target.test_specs.each do |test_spec|
110
+ Xcodeproj::XCScheme.share_scheme(project.path, pod_target.test_target_label(test_spec))
100
111
  end
101
112
  end
102
113
  end
@@ -104,6 +115,8 @@ module Pod
104
115
 
105
116
  private
106
117
 
118
+ InstallationResults = Struct.new(:pod_target_installation_results, :aggregate_target_installation_results)
119
+
107
120
  def create_project
108
121
  if object_version = aggregate_targets.map(&:user_project).compact.map { |p| p.object_version.to_i }.min
109
122
  Pod::Project.new(sandbox.project_path, false, object_version)
@@ -152,60 +165,68 @@ module Pod
152
165
  build_configuration.build_settings['TVOS_DEPLOYMENT_TARGET'] = tvos_deployment_target.to_s if tvos_deployment_target
153
166
  build_configuration.build_settings['STRIP_INSTALLED_PRODUCT'] = 'NO'
154
167
  build_configuration.build_settings['CLANG_ENABLE_OBJC_ARC'] = 'YES'
155
- build_configuration.build_settings['CODE_SIGNING_REQUIRED'] = 'NO'
156
- build_configuration.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
157
168
  end
158
169
  end
159
170
  end
160
171
 
161
172
  def install_file_references
162
- installer = FileReferencesInstaller.new(sandbox, pod_targets, project)
173
+ installer = FileReferencesInstaller.new(sandbox, pod_targets, project, installation_options.preserve_pod_file_structure)
163
174
  installer.install!
164
175
  end
165
176
 
166
- def install_libraries
177
+ def install_targets
167
178
  UI.message '- Installing targets' do
168
179
  umbrella_headers_by_dir = pod_targets.map do |pod_target|
169
180
  next unless pod_target.should_build? && pod_target.defines_module?
170
181
  pod_target.umbrella_header_path
171
182
  end.compact.group_by(&:dirname)
172
183
 
173
- pod_targets.sort_by(&:name).each do |pod_target|
174
- target_installer = PodTargetInstaller.new(sandbox, pod_target)
175
- target_installer.umbrella_headers_by_dir = umbrella_headers_by_dir
176
- target_installer.install!
177
- end
184
+ pod_target_installation_results = Hash[pod_targets.sort_by(&:name).map do |pod_target|
185
+ umbrella_headers_in_header_dir = umbrella_headers_by_dir[pod_target.module_map_path.dirname]
186
+ target_installer = PodTargetInstaller.new(sandbox, @project, pod_target, umbrella_headers_in_header_dir)
187
+ [pod_target.name, target_installer.install!]
188
+ end]
178
189
 
179
- aggregate_targets.sort_by(&:name).each do |target|
180
- target_installer = AggregateTargetInstaller.new(sandbox, target)
181
- target_installer.install!
190
+ # Hook up system framework dependencies for the pod targets that were just installed.
191
+ pod_target_installation_result_values = pod_target_installation_results.values.compact
192
+ unless pod_target_installation_result_values.empty?
193
+ add_system_framework_dependencies(pod_target_installation_result_values)
182
194
  end
183
195
 
184
- add_system_framework_dependencies
196
+ aggregate_target_installation_results = Hash[aggregate_targets.sort_by(&:name).map do |target|
197
+ target_installer = AggregateTargetInstaller.new(sandbox, @project, target)
198
+ [target.name, target_installer.install!]
199
+ end]
200
+
201
+ InstallationResults.new(pod_target_installation_results, aggregate_target_installation_results)
185
202
  end
186
203
  end
187
204
 
188
- def integrate_targets
189
- pod_targets_to_integrate = pod_targets.select { |pt| !pt.test_native_targets.empty? || pt.contains_script_phases? }
190
- unless pod_targets_to_integrate.empty?
205
+ def integrate_targets(pod_target_installation_results)
206
+ pod_installations_to_integrate = pod_target_installation_results.values.select do |pod_target_installation_result|
207
+ pod_target = pod_target_installation_result.target
208
+ !pod_target_installation_result.test_native_targets.empty? || pod_target.contains_script_phases?
209
+ end
210
+ unless pod_installations_to_integrate.empty?
191
211
  UI.message '- Integrating targets' do
192
- pod_targets_to_integrate.each do |pod_target|
193
- PodTargetIntegrator.new(pod_target).integrate!
212
+ pod_installations_to_integrate.each do |pod_target_installation_result|
213
+ PodTargetIntegrator.new(pod_target_installation_result, installation_options).integrate!
194
214
  end
195
215
  end
196
216
  end
197
217
  end
198
218
 
199
- def add_system_framework_dependencies
200
- # @TODO: Add Specs
201
- pod_targets.select(&:should_build?).sort_by(&:name).each do |pod_target|
202
- test_file_accessors, file_accessors = pod_target.file_accessors.partition { |fa| fa.spec.test_specification? }
203
- file_accessors.each do |file_accessor|
204
- add_system_frameworks_to_native_target(file_accessor, pod_target.native_target)
205
- end
206
- test_file_accessors.each do |test_file_accessor|
207
- native_target = pod_target.native_target_for_spec(test_file_accessor.spec)
208
- add_system_frameworks_to_native_target(test_file_accessor, native_target)
219
+ def add_system_framework_dependencies(pod_target_installation_results)
220
+ sorted_installation_results = pod_target_installation_results.sort_by do |pod_target_installation_result|
221
+ pod_target_installation_result.target.name
222
+ end
223
+ sorted_installation_results.each do |target_installation_result|
224
+ pod_target = target_installation_result.target
225
+ next unless pod_target.should_build?
226
+ next if !pod_target.requires_frameworks? || pod_target.static_framework?
227
+ pod_target.file_accessors.each do |file_accessor|
228
+ native_target = target_installation_result.native_target_for_spec(file_accessor.spec)
229
+ add_system_frameworks_to_native_target(native_target, file_accessor)
209
230
  end
210
231
  end
211
232
  end
@@ -213,53 +234,70 @@ module Pod
213
234
  # Adds a target dependency for each pod spec to each aggregate target and
214
235
  # links the pod targets among each other.
215
236
  #
237
+ # @param [Array[Hash{String=>TargetInstallationResult}]] target_installation_results
238
+ # the installation results that were produced when all targets were installed. This includes
239
+ # pod target installation results and aggregate target installation results.
240
+ #
216
241
  # @return [void]
217
242
  #
218
- def set_target_dependencies
243
+ def wire_target_dependencies(target_installation_results)
219
244
  frameworks_group = project.frameworks_group
220
- test_only_pod_targets = pod_targets.dup
221
- aggregate_targets.each do |aggregate_target|
245
+ pod_target_installation_results_hash = target_installation_results.pod_target_installation_results
246
+ aggregate_target_installation_results_hash = target_installation_results.aggregate_target_installation_results
247
+
248
+ # Wire up aggregate targets
249
+ aggregate_target_installation_results_hash.values.each do |aggregate_target_installation_result|
250
+ aggregate_target = aggregate_target_installation_result.target
251
+ aggregate_native_target = aggregate_target_installation_result.native_target
222
252
  is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) &
223
- [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty?
253
+ [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty?
224
254
  is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' }
225
-
255
+ configure_app_extension_api_only_to_native_target(aggregate_native_target) if is_app_extension
256
+ # Wire up dependencies that are part of inherit search paths for this aggregate target.
226
257
  aggregate_target.search_paths_aggregate_targets.each do |search_paths_target|
227
- aggregate_target.native_target.add_dependency(search_paths_target.native_target)
258
+ aggregate_native_target.add_dependency(aggregate_target_installation_results_hash[search_paths_target.name].native_target)
228
259
  end
229
-
260
+ # Wire up all pod target dependencies to aggregate target.
230
261
  aggregate_target.pod_targets.each do |pod_target|
231
- test_only_pod_targets.delete(pod_target)
232
- configure_app_extension_api_only_for_target(aggregate_target) if is_app_extension
233
-
234
- unless pod_target.should_build?
235
- add_resource_bundles_to_native_target(pod_target, aggregate_target.native_target)
236
- add_pod_target_test_dependencies(pod_target, frameworks_group)
237
- next
238
- end
239
-
240
- aggregate_target.native_target.add_dependency(pod_target.native_target)
241
- configure_app_extension_api_only_for_target(pod_target) if is_app_extension
262
+ pod_target_native_target = pod_target_installation_results_hash[pod_target.name].native_target
263
+ aggregate_native_target.add_dependency(pod_target_native_target)
264
+ configure_app_extension_api_only_to_native_target(pod_target_native_target) if is_app_extension
265
+ end
266
+ end
242
267
 
243
- add_dependent_targets_to_native_target(pod_target.dependent_targets,
244
- pod_target.native_target, is_app_extension,
245
- pod_target.requires_frameworks? && !pod_target.static_framework?,
246
- frameworks_group)
247
- unless pod_target.static_framework?
248
- add_pod_target_test_dependencies(pod_target, frameworks_group)
268
+ # Wire up pod targets
269
+ pod_target_installation_results_hash.values.each do |pod_target_installation_result|
270
+ pod_target = pod_target_installation_result.target
271
+ native_target = pod_target_installation_result.native_target
272
+ # First, wire up all resource bundles.
273
+ pod_target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
274
+ native_target.add_dependency(resource_bundle_target)
275
+ if pod_target.requires_frameworks? && pod_target.should_build?
276
+ native_target.add_resources([resource_bundle_target.product_reference])
249
277
  end
250
278
  end
251
- end
252
- # Wire up remaining pod targets used only by tests and are not used by any aggregate target.
253
- test_only_pod_targets.each do |pod_target|
254
- unless pod_target.should_build?
255
- add_pod_target_test_dependencies(pod_target, frameworks_group)
256
- next
279
+ # Wire up all dependencies to this pod target, if any.
280
+ dependent_targets = pod_target.dependent_targets
281
+ dependent_targets.each do |dependent_target|
282
+ native_target.add_dependency(pod_target_installation_results_hash[dependent_target.name].native_target)
283
+ add_framework_file_reference_to_native_target(native_target, pod_target, dependent_target, frameworks_group)
257
284
  end
258
- unless pod_target.static_framework?
259
- add_dependent_targets_to_native_target(pod_target.dependent_targets,
260
- pod_target.native_target, false,
261
- pod_target.requires_frameworks?, frameworks_group)
262
- add_pod_target_test_dependencies(pod_target, frameworks_group)
285
+ # Wire up test native targets.
286
+ unless pod_target_installation_result.test_native_targets.empty?
287
+ pod_target_installation_result.test_specs_by_native_target.each do |test_native_target, test_specs|
288
+ test_dependent_targets = test_specs.flat_map { |s| pod_target.test_dependent_targets_by_spec_name[s.name] }.compact.unshift(pod_target).uniq
289
+ test_dependent_targets.each do |test_dependent_target|
290
+ dependency_installation_result = pod_target_installation_results_hash[test_dependent_target.name]
291
+ resource_bundle_native_targets = dependency_installation_result.test_resource_bundle_targets[test_specs.first.name]
292
+ unless resource_bundle_native_targets.nil?
293
+ resource_bundle_native_targets.each do |test_resource_bundle_target|
294
+ test_native_target.add_dependency(test_resource_bundle_target)
295
+ end
296
+ end
297
+ test_native_target.add_dependency(dependency_installation_result.native_target)
298
+ add_framework_file_reference_to_native_target(test_native_target, pod_target, test_dependent_target, frameworks_group)
299
+ end
300
+ end
263
301
  end
264
302
  end
265
303
  end
@@ -295,55 +333,25 @@ module Pod
295
333
 
296
334
  # @! group Private Helpers
297
335
 
298
- private
299
-
300
- def add_pod_target_test_dependencies(pod_target, frameworks_group)
301
- test_dependent_targets = pod_target.all_dependent_targets
302
- pod_target.test_specs_by_native_target.each do |test_native_target, test_specs|
303
- test_dependent_targets.reject(&:should_build?).each do |test_dependent_target|
304
- add_resource_bundles_to_native_target(test_dependent_target, test_native_target)
305
- end
306
- add_dependent_targets_to_native_target(test_dependent_targets, test_native_target, false, pod_target.requires_frameworks?, frameworks_group)
307
- test_spec_consumers = test_specs.map { |test_spec| test_spec.consumer(pod_target.platform) }
308
- if test_spec_consumers.any?(&:requires_app_host?)
309
- app_host_target = project.targets.find { |t| t.name == pod_target.app_host_label(test_specs.first.test_type) }
310
- test_native_target.add_dependency(app_host_target)
311
- end
312
- end
313
- end
314
-
315
- def add_dependent_targets_to_native_target(dependent_targets, native_target, is_app_extension, requires_frameworks, frameworks_group)
316
- dependent_targets.each do |pod_dependency_target|
317
- next unless pod_dependency_target.should_build?
318
- native_target.add_dependency(pod_dependency_target.native_target)
319
- configure_app_extension_api_only_for_target(pod_dependency_target) if is_app_extension
320
-
321
- if requires_frameworks
322
- product_ref = frameworks_group.files.find { |f| f.path == pod_dependency_target.product_name } ||
323
- frameworks_group.new_product_ref_for_target(pod_dependency_target.product_basename, pod_dependency_target.product_type)
324
- native_target.frameworks_build_phase.add_file_reference(product_ref, true)
325
- end
326
- end
327
- end
328
-
329
- def add_system_frameworks_to_native_target(file_accessor, native_target)
336
+ def add_system_frameworks_to_native_target(native_target, file_accessor)
330
337
  file_accessor.spec_consumer.frameworks.each do |framework|
331
338
  native_target.add_system_framework(framework)
332
339
  end
333
340
  end
334
341
 
335
- def add_resource_bundles_to_native_target(dependent_target, native_target)
336
- resource_bundle_targets = dependent_target.resource_bundle_targets + dependent_target.test_resource_bundle_targets
337
- resource_bundle_targets.each do |resource_bundle_target|
338
- native_target.add_dependency(resource_bundle_target)
342
+ def add_framework_file_reference_to_native_target(native_target, pod_target, dependent_target, frameworks_group)
343
+ if pod_target.should_build? && pod_target.requires_frameworks? && !pod_target.static_framework? && dependent_target.should_build?
344
+ product_ref = frameworks_group.files.find { |f| f.path == dependent_target.product_name } ||
345
+ frameworks_group.new_product_ref_for_target(dependent_target.product_basename, dependent_target.product_type)
346
+ native_target.frameworks_build_phase.add_file_reference(product_ref, true)
339
347
  end
340
348
  end
341
349
 
342
350
  # Sets the APPLICATION_EXTENSION_API_ONLY build setting to YES for all
343
- # configurations of the given target
351
+ # configurations of the given native target.
344
352
  #
345
- def configure_app_extension_api_only_for_target(target)
346
- target.native_target.build_configurations.each do |config|
353
+ def configure_app_extension_api_only_to_native_target(native_target)
354
+ native_target.build_configurations.each do |config|
347
355
  config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'YES'
348
356
  end
349
357
  end
@@ -34,7 +34,7 @@ module Pod
34
34
  def validate!
35
35
  verify_no_duplicate_framework_and_library_names
36
36
  verify_no_static_framework_transitive_dependencies
37
- verify_no_pods_used_with_multiple_swift_versions
37
+ verify_swift_pods_swift_version
38
38
  verify_swift_pods_have_module_dependencies
39
39
  end
40
40
 
@@ -91,22 +91,28 @@ module Pod
91
91
  end
92
92
  end
93
93
 
94
- def verify_no_pods_used_with_multiple_swift_versions
95
- error_message_for_target = lambda do |target|
96
- "#{target.name} (Swift #{target.swift_version})"
94
+ def verify_swift_pods_swift_version
95
+ error_message_for_target_definition = lambda do |target_definition|
96
+ "`#{target_definition.name}` (Swift #{target_definition.swift_version})"
97
97
  end
98
98
  swift_pod_targets = pod_targets.select(&:uses_swift?)
99
99
  error_messages = swift_pod_targets.map do |pod_target|
100
100
  next unless pod_target.spec_swift_version.nil?
101
101
  swift_target_definitions = pod_target.target_definitions.reject { |target| target.swift_version.blank? }
102
- next if swift_target_definitions.empty? || swift_target_definitions.uniq(&:swift_version).count == 1
103
- target_errors = swift_target_definitions.map(&error_message_for_target).join(', ')
104
- "- #{pod_target.name} required by #{target_errors}"
102
+ next if swift_target_definitions.uniq(&:swift_version).count == 1
103
+ if swift_target_definitions.empty?
104
+ "- `#{pod_target.name}` does not specify a Swift version and none of the targets " \
105
+ "(#{pod_target.target_definitions.map { |td| "`#{td.name}`" }.to_sentence}) integrating it have the " \
106
+ '`SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at ' \
107
+ 'least one of the targets that integrate this pod.'
108
+ else
109
+ target_errors = swift_target_definitions.map(&error_message_for_target_definition).to_sentence
110
+ "- `#{pod_target.name}` is integrated by multiple targets that use a different Swift version: #{target_errors}."
111
+ end
105
112
  end.compact
106
113
 
107
114
  unless error_messages.empty?
108
- raise Informative, 'The following pods are integrated into targets ' \
109
- "that do not have the same Swift version:\n\n#{error_messages.join("\n")}"
115
+ raise Informative, "Unable to determine Swift version for the following pods:\n\n#{error_messages.join("\n")}"
110
116
  end
111
117
  end
112
118