cocoapods 1.6.2 → 1.7.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +101 -7
  3. data/README.md +9 -9
  4. data/lib/cocoapods.rb +2 -0
  5. data/lib/cocoapods/command.rb +1 -1
  6. data/lib/cocoapods/command/init.rb +2 -12
  7. data/lib/cocoapods/command/install.rb +3 -0
  8. data/lib/cocoapods/command/lib/create.rb +1 -1
  9. data/lib/cocoapods/command/lib/lint.rb +5 -1
  10. data/lib/cocoapods/command/list.rb +3 -5
  11. data/lib/cocoapods/command/repo.rb +1 -0
  12. data/lib/cocoapods/command/repo/add.rb +4 -5
  13. data/lib/cocoapods/command/repo/add_cdn.rb +58 -0
  14. data/lib/cocoapods/command/repo/list.rb +5 -6
  15. data/lib/cocoapods/command/repo/push.rb +6 -5
  16. data/lib/cocoapods/command/spec/create.rb +12 -12
  17. data/lib/cocoapods/command/spec/lint.rb +1 -1
  18. data/lib/cocoapods/command/update.rb +3 -0
  19. data/lib/cocoapods/config.rb +1 -0
  20. data/lib/cocoapods/executable.rb +32 -7
  21. data/lib/cocoapods/gem_version.rb +1 -1
  22. data/lib/cocoapods/generator/app_target_helper.rb +1 -1
  23. data/lib/cocoapods/generator/embed_frameworks_script.rb +13 -0
  24. data/lib/cocoapods/generator/file_list.rb +39 -0
  25. data/lib/cocoapods/generator/module_map.rb +1 -1
  26. data/lib/cocoapods/installer.rb +188 -46
  27. data/lib/cocoapods/installer/analyzer.rb +64 -39
  28. data/lib/cocoapods/installer/analyzer/pod_variant.rb +14 -9
  29. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +11 -2
  30. data/lib/cocoapods/installer/installation_options.rb +70 -44
  31. data/lib/cocoapods/installer/pod_source_installer.rb +9 -4
  32. data/lib/cocoapods/installer/podfile_validator.rb +9 -0
  33. data/lib/cocoapods/installer/post_install_hooks_context.rb +5 -2
  34. data/lib/cocoapods/installer/project_cache/project_cache.rb +11 -0
  35. data/lib/cocoapods/installer/project_cache/project_cache_analysis_result.rb +53 -0
  36. data/lib/cocoapods/installer/project_cache/project_cache_analyzer.rb +156 -0
  37. data/lib/cocoapods/installer/project_cache/project_cache_version.rb +43 -0
  38. data/lib/cocoapods/installer/project_cache/project_installation_cache.rb +77 -0
  39. data/lib/cocoapods/installer/project_cache/project_metadata_cache.rb +63 -0
  40. data/lib/cocoapods/installer/project_cache/target_cache_key.rb +134 -0
  41. data/lib/cocoapods/installer/project_cache/target_metadata.rb +70 -0
  42. data/lib/cocoapods/installer/sandbox_dir_cleaner.rb +89 -0
  43. data/lib/cocoapods/installer/sandbox_header_paths_installer.rb +45 -0
  44. data/lib/cocoapods/installer/target_uuid_generator.rb +32 -0
  45. data/lib/cocoapods/installer/user_project_integrator.rb +8 -6
  46. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +128 -63
  47. data/lib/cocoapods/installer/xcode.rb +3 -0
  48. data/lib/cocoapods/installer/xcode/multi_pods_project_generator.rb +72 -0
  49. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +102 -218
  50. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb +75 -0
  51. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +1 -1
  52. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +29 -17
  53. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +31 -65
  54. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +155 -0
  55. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +265 -110
  56. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +70 -43
  57. data/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb +75 -0
  58. data/lib/cocoapods/installer/xcode/pods_project_generator/project_generator.rb +119 -0
  59. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +44 -7
  60. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +5 -7
  61. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +32 -0
  62. data/lib/cocoapods/installer/xcode/pods_project_generator_result.rb +35 -0
  63. data/lib/cocoapods/installer/xcode/single_pods_project_generator.rb +38 -0
  64. data/lib/cocoapods/installer/xcode/target_validator.rb +32 -25
  65. data/lib/cocoapods/native_target_extension.rb +54 -0
  66. data/lib/cocoapods/open-uri.rb +1 -1
  67. data/lib/cocoapods/podfile.rb +13 -0
  68. data/lib/cocoapods/project.rb +88 -10
  69. data/lib/cocoapods/resolver.rb +11 -8
  70. data/lib/cocoapods/resolver/resolver_specification.rb +7 -7
  71. data/lib/cocoapods/sandbox.rb +38 -9
  72. data/lib/cocoapods/sandbox/file_accessor.rb +21 -0
  73. data/lib/cocoapods/sandbox/headers_store.rb +18 -3
  74. data/lib/cocoapods/sandbox/pod_dir_cleaner.rb +1 -14
  75. data/lib/cocoapods/sources_manager.rb +11 -3
  76. data/lib/cocoapods/target.rb +67 -7
  77. data/lib/cocoapods/target/aggregate_target.rb +70 -8
  78. data/lib/cocoapods/target/build_settings.rb +124 -65
  79. data/lib/cocoapods/target/build_type.rb +139 -0
  80. data/lib/cocoapods/target/framework_paths.rb +12 -7
  81. data/lib/cocoapods/target/pod_target.rb +322 -65
  82. data/lib/cocoapods/user_interface.rb +2 -2
  83. data/lib/cocoapods/user_interface/error_report.rb +3 -0
  84. data/lib/cocoapods/user_interface/inspector_reporter.rb +1 -1
  85. data/lib/cocoapods/validator.rb +74 -39
  86. data/lib/cocoapods/version_metadata.rb +7 -0
  87. metadata +30 -6
@@ -31,37 +31,43 @@ module Pod
31
31
  def install!
32
32
  UI.message "- Installing target `#{target.name}` #{target.platform}" do
33
33
  create_support_files_dir
34
- test_file_accessors, file_accessors = target.file_accessors.partition { |fa| fa.spec.test_specification? }
34
+ library_file_accessors = target.file_accessors.select { |fa| fa.spec.library_specification? }
35
+ test_file_accessors = target.file_accessors.select { |fa| fa.spec.test_specification? }
36
+ app_file_accessors = target.file_accessors.select { |fa| fa.spec.app_specification? }
35
37
 
36
38
  unless target.should_build?
37
39
  # For targets that should not be built (e.g. pre-built vendored frameworks etc), we add a placeholder
38
40
  # PBXAggregateTarget that will be used to wire up dependencies later.
39
41
  native_target = add_placeholder_target
40
- resource_bundle_targets = add_resources_bundle_targets(file_accessors).values.flatten
42
+ resource_bundle_targets = add_resources_bundle_targets(library_file_accessors).values.flatten
41
43
  create_xcconfig_file(native_target, resource_bundle_targets)
42
44
  return TargetInstallationResult.new(target, native_target, resource_bundle_targets)
43
45
  end
44
46
 
45
47
  native_target = add_target
46
- resource_bundle_targets = add_resources_bundle_targets(file_accessors).values.flatten
48
+ resource_bundle_targets = add_resources_bundle_targets(library_file_accessors).values.flatten
47
49
 
48
50
  test_native_targets = add_test_targets
49
51
  test_app_host_targets = add_test_app_host_targets(test_native_targets)
50
52
  test_resource_bundle_targets = add_resources_bundle_targets(test_file_accessors)
51
53
 
52
- add_files_to_build_phases(native_target, test_native_targets)
53
- validate_targets_contain_sources(test_native_targets + [native_target])
54
+ app_native_targets = add_app_targets
55
+ app_resource_bundle_targets = add_resources_bundle_targets(app_file_accessors)
56
+
57
+ add_files_to_build_phases(native_target, test_native_targets, app_native_targets)
58
+ validate_targets_contain_sources(test_native_targets + app_native_targets + [native_target])
54
59
 
55
60
  create_xcconfig_file(native_target, resource_bundle_targets)
56
61
  create_test_xcconfig_files(test_native_targets, test_resource_bundle_targets)
62
+ create_app_xcconfig_files(app_native_targets, app_resource_bundle_targets)
57
63
 
58
64
  if target.defines_module?
59
65
  create_module_map(native_target) do |generator|
60
66
  generator.headers.concat module_map_additional_headers
61
67
  end
62
68
  create_umbrella_header(native_target) do |generator|
63
- generator.imports += file_accessors.flat_map do |file_accessor|
64
- header_dir = if !target.requires_frameworks? && dir = file_accessor.spec_consumer.header_dir
69
+ generator.imports += library_file_accessors.flat_map do |file_accessor|
70
+ header_dir = if !target.build_as_framework? && dir = file_accessor.spec_consumer.header_dir
65
71
  Pathname.new(dir)
66
72
  end
67
73
 
@@ -80,36 +86,82 @@ module Pod
80
86
  end
81
87
  end
82
88
 
83
- if target.requires_frameworks?
89
+ if target.build_as_framework?
84
90
  unless skip_info_plist?(native_target)
85
91
  create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
86
92
  end
87
93
  create_build_phase_to_symlink_header_folders(native_target)
88
- elsif target.uses_swift?
89
- add_swift_static_library_compatibility_header_phase(native_target)
90
94
  end
91
95
 
92
- unless skip_pch?(target.non_test_specs)
96
+ if target.build_as_library? && target.uses_swift?
97
+ add_swift_library_compatibility_header_phase(native_target)
98
+ end
99
+
100
+ project_directory = project.path.dirname
101
+
102
+ unless skip_pch?(target.library_specs)
93
103
  path = target.prefix_header_path
94
- create_prefix_header(path, file_accessors, target.platform, native_target)
104
+ create_prefix_header(path, library_file_accessors, target.platform, native_target, project_directory)
105
+ add_file_to_support_group(path)
95
106
  end
96
107
  unless skip_pch?(target.test_specs)
97
108
  target.test_specs.each do |test_spec|
98
- path = target.prefix_header_path_for_test_spec(test_spec)
109
+ path = target.prefix_header_path_for_spec(test_spec)
99
110
  test_spec_consumer = test_spec.consumer(target.platform)
100
- test_native_target = test_native_target_from_spec_consumer(test_spec_consumer, test_native_targets)
101
- create_prefix_header(path, test_file_accessors, target.platform, test_native_target)
111
+ test_native_target = test_native_target_from_spec(test_spec_consumer.spec, test_native_targets)
112
+ create_prefix_header(path, test_file_accessors, target.platform, test_native_target, project_directory)
113
+ add_file_to_support_group(path)
114
+ end
115
+ end
116
+ unless skip_pch?(target.app_specs)
117
+ target.app_specs.each do |app_spec|
118
+ path = target.prefix_header_path_for_spec(app_spec)
119
+ app_spec_consumer = app_spec.consumer(target.platform)
120
+ app_native_target = app_native_target_from_spec(app_spec_consumer.spec, app_native_targets)
121
+ create_prefix_header(path, app_file_accessors, target.platform, app_native_target, project_directory)
122
+ add_file_to_support_group(path)
102
123
  end
103
124
  end
104
125
  create_dummy_source(native_target)
105
126
  clean_support_files_temp_dir
106
- TargetInstallationResult.new(target, native_target, resource_bundle_targets, test_native_targets,
107
- test_resource_bundle_targets, test_app_host_targets)
127
+ TargetInstallationResult.new(target, native_target, resource_bundle_targets,
128
+ test_native_targets, test_resource_bundle_targets, test_app_host_targets,
129
+ app_native_targets, app_resource_bundle_targets)
108
130
  end
109
131
  end
110
132
 
111
133
  private
112
134
 
135
+ # Adds the target for the library to the Pods project with the
136
+ # appropriate build configurations.
137
+ #
138
+ # @note Overrides the superclass implementation to remove settings that are set in the pod target xcconfig
139
+ #
140
+ # @return [PBXNativeTarget] the native target that was added.
141
+ #
142
+ def add_target
143
+ super.tap do |native_target|
144
+ remove_pod_target_xcconfig_overrides_from_target(target.build_settings, native_target)
145
+ end
146
+ end
147
+
148
+ # Removes overrides of the `pod_target_xcconfig` settings from the target's
149
+ # build configurations.
150
+ #
151
+ # @return [Void]
152
+ #
153
+ # @param [Target::BuildSettings] build_settings
154
+ #
155
+ # @param [PBXNativeTarget] native_target
156
+ #
157
+ def remove_pod_target_xcconfig_overrides_from_target(build_settings, native_target)
158
+ native_target.build_configurations.each do |configuration|
159
+ build_settings.merged_pod_target_xcconfigs.each_key do |setting|
160
+ configuration.build_settings.delete(setting)
161
+ end
162
+ end
163
+ end
164
+
113
165
  # @param [Array<Specification>] specs
114
166
  # the specs to check against whether `.pch` generation should be skipped or not.
115
167
  #
@@ -137,7 +189,7 @@ module Pod
137
189
  #
138
190
  def custom_build_settings
139
191
  settings = super
140
- unless target.requires_frameworks?
192
+ unless target.build_as_framework?
141
193
  settings['PRIVATE_HEADERS_FOLDER_PATH'] = ''
142
194
  settings['PUBLIC_HEADERS_FOLDER_PATH'] = ''
143
195
  end
@@ -195,9 +247,8 @@ module Pod
195
247
  ref
196
248
  end.compact.uniq
197
249
  compile_phase_matcher = lambda { |ref| !(ref.path =~ /.*\.xcdatamodeld/i).nil? }
198
- resources_phase_refs = file_references.reject(&compile_phase_matcher)
199
- compile_phase_refs = file_references.select(&compile_phase_matcher)
200
- yield resources_phase_refs, compile_phase_refs
250
+ compile_phase_refs, resources_phase_refs = file_references.partition(&compile_phase_matcher)
251
+ yield compile_phase_refs, resources_phase_refs
201
252
  end
202
253
 
203
254
  #-----------------------------------------------------------------------#
@@ -215,15 +266,18 @@ module Pod
215
266
  #
216
267
  # @return [void]
217
268
  #
218
- def add_files_to_build_phases(native_target, test_native_targets)
269
+ def add_files_to_build_phases(native_target, test_native_targets, app_native_targets)
219
270
  target.file_accessors.each do |file_accessor|
220
271
  consumer = file_accessor.spec_consumer
221
272
 
222
- native_target = if !consumer.spec.test_specification?
223
- native_target
224
- else
225
- test_native_target_from_spec_consumer(consumer, test_native_targets)
226
- end
273
+ native_target = case consumer.spec.spec_type
274
+ when :library
275
+ native_target
276
+ when :test
277
+ test_native_target_from_spec(consumer.spec, test_native_targets)
278
+ when :app
279
+ app_native_target_from_spec(consumer.spec, app_native_targets)
280
+ end
227
281
 
228
282
  headers = file_accessor.headers
229
283
  public_headers = file_accessor.public_headers.map(&:realpath)
@@ -249,9 +303,9 @@ module Pod
249
303
  other_file_refs = project_file_references_array(other_source_files, 'other source')
250
304
  native_target.add_file_references(other_file_refs, nil)
251
305
 
252
- next unless target.requires_frameworks?
306
+ next unless target.build_as_dynamic_framework?
253
307
 
254
- filter_resource_file_references(file_accessor.resources.flatten) do |resource_phase_refs, compile_phase_refs|
308
+ filter_resource_file_references(file_accessor.resources.flatten) do |compile_phase_refs, resource_phase_refs|
255
309
  native_target.add_file_references(compile_phase_refs, nil)
256
310
  native_target.add_resources(resource_phase_refs)
257
311
  end
@@ -270,7 +324,7 @@ module Pod
270
324
  product_type = target.product_type_for_test_type(test_type)
271
325
  name = target.test_target_label(test_spec)
272
326
  platform_name = target.platform.name
273
- language = target.uses_swift_for_test_spec?(test_spec) ? :swift : :objc
327
+ language = target.uses_swift_for_spec?(test_spec) ? :swift : :objc
274
328
  test_native_target = project.new_target(product_type, name, platform_name, deployment_target, nil, language)
275
329
  test_native_target.product_reference.name = name
276
330
 
@@ -303,6 +357,8 @@ module Pod
303
357
  configuration.build_settings['CODE_SIGN_IDENTITY'] = '' if target.platform == :osx
304
358
  end
305
359
 
360
+ remove_pod_target_xcconfig_overrides_from_target(target.build_settings_for_spec(test_spec), test_native_target)
361
+
306
362
  # Test native targets also need frameworks and resources to be copied over to their xctest bundle.
307
363
  create_test_target_embed_frameworks_script(test_spec)
308
364
  create_test_target_copy_resources_script(test_spec)
@@ -310,7 +366,7 @@ module Pod
310
366
  # Generate vanilla Info.plist for test target similar to the one Xcode generates for new test target.
311
367
  # This creates valid test bundle accessible at the runtime, allowing tests to load bundle resources
312
368
  # defined in podspec.
313
- create_info_plist_file(target.info_plist_path_for_test_spec(test_spec), test_native_target, '1.0', target.platform, :bndl)
369
+ create_info_plist_file(target.info_plist_path_for_spec(test_spec), test_native_target, '1.0', target.platform, :bndl)
314
370
 
315
371
  test_native_target
316
372
  end
@@ -328,10 +384,10 @@ module Pod
328
384
  target.test_spec_consumers.select(&:requires_app_host?).group_by(&:test_type).map do |test_type, test_spec_consumers|
329
385
  platform = target.platform
330
386
  name = "AppHost-#{target.label}-#{test_type.capitalize}-Tests"
331
- app_host_target = AppHostInstaller.new(sandbox, project, platform, name, target.pod_name).install!
387
+ app_host_target = AppHostInstaller.new(sandbox, project, platform, name, target.pod_name, name).install!
332
388
  # Wire test native targets to the generated app host.
333
389
  test_spec_consumers.each do |test_spec_consumer|
334
- test_native_target = test_native_target_from_spec_consumer(test_spec_consumer, test_native_targets)
390
+ test_native_target = test_native_target_from_spec(test_spec_consumer.spec, test_native_targets)
335
391
  test_native_target.build_configurations.each do |configuration|
336
392
  test_host = "$(BUILT_PRODUCTS_DIR)/#{app_host_target.name}.app/"
337
393
  test_host << 'Contents/MacOS/' if platform == :osx
@@ -347,6 +403,79 @@ module Pod
347
403
  end
348
404
  end
349
405
 
406
+ # Adds the app targets for the library to the Pods project with the
407
+ # appropriate build configurations.
408
+ #
409
+ # @return [Array<PBXNativeTarget>] the app native targets created.
410
+ #
411
+ def add_app_targets
412
+ target.app_specs.map do |app_spec|
413
+ spec_name = app_spec.parent.name
414
+ subspec_name = target.subspec_label(app_spec)
415
+ app_target_label = target.app_target_label(app_spec)
416
+ platform = target.platform
417
+ app_native_target = AppHostInstaller.new(sandbox, project, platform, subspec_name, spec_name,
418
+ app_target_label, :add_main => false).install!
419
+
420
+ app_native_target.product_reference.name = app_target_label
421
+ target.user_build_configurations.each do |bc_name, type|
422
+ app_native_target.add_build_configuration(bc_name, type)
423
+ end
424
+
425
+ app_native_target.build_configurations.each do |configuration|
426
+ configuration.build_settings.merge!(custom_build_settings)
427
+
428
+ # target_installer will automatically add an empty `OTHER_LDFLAGS`. For app
429
+ # targets those are set via an app xcconfig file instead.
430
+ configuration.build_settings.delete('OTHER_LDFLAGS')
431
+ # target_installer will automatically set the product name to the module name if the target
432
+ # requires frameworks. For apps we always use the app target name as the product name
433
+ # irrelevant to whether we use frameworks or not.
434
+ configuration.build_settings['PRODUCT_NAME'] = app_target_label
435
+ # target_installer sets 'MACH_O_TYPE' for static frameworks ensure this does not propagate
436
+ # to app target.
437
+ configuration.build_settings.delete('MACH_O_TYPE')
438
+ # Use xcode default product module name, which is $(PRODUCT_NAME:c99extidentifier)
439
+ # this gives us always valid name that is distinct from the parent spec module name
440
+ # which allow the app to use import to access the parent framework
441
+ configuration.build_settings.delete('PRODUCT_MODULE_NAME')
442
+
443
+ # We must codesign iOS app bundles that contain binary frameworks to allow them to be launchable in the simulator
444
+ unless target.platform == :osx
445
+ configuration.build_settings['CODE_SIGNING_REQUIRED'] = 'YES'
446
+ configuration.build_settings['CODE_SIGNING_ALLOWED'] = 'YES'
447
+ end
448
+ # For macOS we do not code sign the appbundle because we do not code sign the frameworks either.
449
+ configuration.build_settings['CODE_SIGN_IDENTITY'] = '' if target.platform == :osx
450
+ end
451
+
452
+ remove_pod_target_xcconfig_overrides_from_target(target.build_settings_for_spec(app_spec), app_native_target)
453
+
454
+ create_app_target_embed_frameworks_script(app_spec)
455
+ create_app_target_copy_resources_script(app_spec)
456
+ add_resources_to_target(target.file_accessors.find { |fa| fa.spec == app_spec }.resources, app_native_target)
457
+
458
+ app_native_target
459
+ end
460
+ end
461
+
462
+ # Adds the resources to the compile resources phase of the target.
463
+ #
464
+ # @param [Array<Pathname>] paths the paths to add to the target.
465
+ #
466
+ # @param [PBXNativeTarget] target the target resources are added to.
467
+ #
468
+ # @return [Boolean] whether any compile phase references were added.
469
+ #
470
+ def add_resources_to_target(paths, target)
471
+ filter_resource_file_references(paths) do |compile_phase_refs, resource_phase_refs|
472
+ # Resource bundles are only meant to have resources, so install everything
473
+ # into the resources phase. See note in filter_resource_file_references.
474
+ target.add_resources(resource_phase_refs + compile_phase_refs)
475
+ !compile_phase_refs.empty?
476
+ end
477
+ end
478
+
350
479
  # Adds the resources of the Pods to the Pods project.
351
480
  #
352
481
  # @note The source files are grouped by Pod and in turn by subspec
@@ -355,7 +484,7 @@ module Pod
355
484
  # @param [Array<Sandbox::FileAccessor>] file_accessors
356
485
  # the file accessors list to generate resource bundles for.
357
486
  #
358
- # @return [Array<PBXNativeTarget] the resource bundle native targets created.
487
+ # @return [Array<PBXNativeTarget>] the resource bundle native targets created.
359
488
  #
360
489
  def add_resources_bundle_targets(file_accessors)
361
490
  file_accessors.each_with_object({}) do |file_accessor, hash|
@@ -367,13 +496,7 @@ module Pod
367
496
  bundle_product.name = bundle_file_name
368
497
  end
369
498
 
370
- contains_compile_phase_refs = false
371
- filter_resource_file_references(paths) do |resource_phase_refs, compile_phase_refs|
372
- # Resource bundles are only meant to have resources, so install everything
373
- # into the resources phase. See note in filter_resource_file_references.
374
- resource_bundle_target.add_resources(resource_phase_refs + compile_phase_refs)
375
- contains_compile_phase_refs = !compile_phase_refs.empty?
376
- end
499
+ contains_compile_phase_refs = add_resources_to_target(paths, resource_bundle_target)
377
500
 
378
501
  target.user_build_configurations.each do |bc_name, type|
379
502
  resource_bundle_target.add_build_configuration(bc_name, type)
@@ -397,7 +520,7 @@ module Pod
397
520
 
398
521
  # Set the `SWIFT_VERSION` build setting for resource bundles that could have resources that get
399
522
  # compiled such as an `xcdatamodeld` file which has 'Swift' as its code generation language.
400
- if contains_compile_phase_refs && target.uses_swift?
523
+ if contains_compile_phase_refs && file_accessors.any? { |fa| target.uses_swift_for_spec?(fa.spec) }
401
524
  configuration.build_settings['SWIFT_VERSION'] = target.swift_version
402
525
  end
403
526
 
@@ -413,6 +536,8 @@ module Pod
413
536
  end
414
537
  end
415
538
 
539
+ remove_pod_target_xcconfig_overrides_from_target(target.build_settings_for_spec(file_accessor.spec), resource_bundle_target)
540
+
416
541
  resource_bundle_target
417
542
  end
418
543
  end
@@ -433,12 +558,8 @@ module Pod
433
558
  update_changed_file(target.build_settings, path)
434
559
  xcconfig_file_ref = add_file_to_support_group(path)
435
560
 
436
- native_target.build_configurations.each do |c|
437
- c.base_configuration_reference = xcconfig_file_ref
438
- end
439
-
440
561
  # also apply the private config to resource bundle targets.
441
- apply_xcconfig_file_ref_to_resource_bundle_targets(resource_bundle_targets, xcconfig_file_ref)
562
+ apply_xcconfig_file_ref_to_targets([native_target] + resource_bundle_targets, xcconfig_file_ref)
442
563
  end
443
564
 
444
565
  # Generates the contents of the xcconfig file used for each test target type and saves it to disk.
@@ -455,21 +576,19 @@ module Pod
455
576
  target.test_specs.each do |test_spec|
456
577
  spec_consumer = test_spec.consumer(target.platform)
457
578
  test_type = spec_consumer.test_type
458
- path = target.xcconfig_path("#{test_type.capitalize}-#{test_spec.name.split('/')[1..-1].join('-')}")
459
- update_changed_file(Target::BuildSettings::PodTargetSettings.new(target, test_spec), path)
579
+ path = target.xcconfig_path("#{test_type.capitalize}-#{target.subspec_label(test_spec)}")
580
+ test_spec_build_settings = target.build_settings_for_spec(test_spec)
581
+ update_changed_file(test_spec_build_settings, path)
460
582
  test_xcconfig_file_ref = add_file_to_support_group(path)
461
583
 
462
- test_native_target = test_native_target_from_spec_consumer(spec_consumer, test_native_targets)
584
+ test_native_target = test_native_target_from_spec(spec_consumer.spec, test_native_targets)
463
585
  test_native_target.build_configurations.each do |test_native_target_bc|
464
586
  test_target_swift_debug_hack(test_spec, test_native_target_bc)
465
- test_native_target_bc.base_configuration_reference = test_xcconfig_file_ref
466
587
  end
467
588
 
468
589
  # also apply the private config to resource bundle test targets related to this test spec.
469
590
  scoped_test_resource_bundle_targets = test_resource_bundle_targets[test_spec.name]
470
- unless scoped_test_resource_bundle_targets.empty?
471
- apply_xcconfig_file_ref_to_resource_bundle_targets(scoped_test_resource_bundle_targets, test_xcconfig_file_ref)
472
- end
591
+ apply_xcconfig_file_ref_to_targets([test_native_target] + scoped_test_resource_bundle_targets, test_xcconfig_file_ref)
473
592
  end
474
593
  end
475
594
 
@@ -481,11 +600,11 @@ module Pod
481
600
  # @return [void]
482
601
  #
483
602
  def create_test_target_copy_resources_script(test_spec)
484
- path = target.copy_resources_script_path_for_test_spec(test_spec)
603
+ path = target.copy_resources_script_path_for_spec(test_spec)
485
604
  pod_targets = target.dependent_targets_for_test_spec(test_spec)
486
605
  resource_paths_by_config = target.user_build_configurations.keys.each_with_object({}) do |config, resources_by_config|
487
606
  resources_by_config[config] = pod_targets.flat_map do |pod_target|
488
- spec_paths_to_include = pod_target.non_test_specs.map(&:name)
607
+ spec_paths_to_include = pod_target.library_specs.map(&:name)
489
608
  spec_paths_to_include << test_spec.name if pod_target == target
490
609
  pod_target.resource_paths.values_at(*spec_paths_to_include).flatten.compact
491
610
  end
@@ -503,11 +622,11 @@ module Pod
503
622
  # @return [void]
504
623
  #
505
624
  def create_test_target_embed_frameworks_script(test_spec)
506
- path = target.embed_frameworks_script_path_for_test_spec(test_spec)
625
+ path = target.embed_frameworks_script_path_for_spec(test_spec)
507
626
  pod_targets = target.dependent_targets_for_test_spec(test_spec)
508
627
  framework_paths_by_config = target.user_build_configurations.keys.each_with_object({}) do |config, paths_by_config|
509
628
  paths_by_config[config] = pod_targets.flat_map do |pod_target|
510
- spec_paths_to_include = pod_target.non_test_specs.map(&:name)
629
+ spec_paths_to_include = pod_target.library_specs.map(&:name)
511
630
  spec_paths_to_include << test_spec.name if pod_target == target
512
631
  pod_target.framework_paths.values_at(*spec_paths_to_include).flatten.compact.uniq
513
632
  end
@@ -517,6 +636,75 @@ module Pod
517
636
  add_file_to_support_group(path)
518
637
  end
519
638
 
639
+ # Generates the contents of the xcconfig file used for each app target type and saves it to disk.
640
+ #
641
+ # @param [Array<PBXNativeTarget>] app_native_targets
642
+ # the app native target to link the xcconfig file into.
643
+ #
644
+ # @param [Hash{String=>Array<PBXNativeTarget>}] app_resource_bundle_targets
645
+ # the additional app resource bundle targets to link the xcconfig file into.
646
+ #
647
+ # @return [void]
648
+ #
649
+ def create_app_xcconfig_files(app_native_targets, app_resource_bundle_targets)
650
+ target.app_specs.each do |app_spec|
651
+ spec_consumer = app_spec.consumer(target.platform)
652
+ path = target.xcconfig_path(target.subspec_label(app_spec))
653
+ update_changed_file(target.build_settings_for_spec(app_spec), path)
654
+ app_xcconfig_file_ref = add_file_to_support_group(path)
655
+
656
+ app_native_target = app_native_target_from_spec(spec_consumer.spec, app_native_targets)
657
+
658
+ # also apply the private config to resource bundle app targets related to this app spec.
659
+ scoped_app_resource_bundle_targets = app_resource_bundle_targets[app_spec.name]
660
+ apply_xcconfig_file_ref_to_targets([app_native_target] + scoped_app_resource_bundle_targets, app_xcconfig_file_ref)
661
+ end
662
+ end
663
+
664
+ # Creates a script that copies the resources to the bundle of the app target.
665
+ #
666
+ # @param [Specification] app_spec
667
+ # The app spec to create the copy resources script for.
668
+ #
669
+ # @return [void]
670
+ #
671
+ def create_app_target_copy_resources_script(app_spec)
672
+ path = target.copy_resources_script_path_for_spec(app_spec)
673
+ pod_targets = target.dependent_targets_for_app_spec(app_spec)
674
+ resource_paths_by_config = target.user_build_configurations.keys.each_with_object({}) do |config, resources_by_config|
675
+ resources_by_config[config] = pod_targets.flat_map do |pod_target|
676
+ spec_paths_to_include = pod_target.library_specs.map(&:name)
677
+ spec_paths_to_include << app_spec.name if pod_target == target
678
+ pod_target.resource_paths.values_at(*spec_paths_to_include).flatten.compact
679
+ end
680
+ end
681
+ generator = Generator::CopyResourcesScript.new(resource_paths_by_config, target.platform)
682
+ update_changed_file(generator, path)
683
+ add_file_to_support_group(path)
684
+ end
685
+
686
+ # Creates a script that embeds the frameworks to the bundle of the app target.
687
+ #
688
+ # @param [Specification] app_spec
689
+ # The app spec to create the embed frameworks script for.
690
+ #
691
+ # @return [void]
692
+ #
693
+ def create_app_target_embed_frameworks_script(app_spec)
694
+ path = target.embed_frameworks_script_path_for_spec(app_spec)
695
+ pod_targets = target.dependent_targets_for_app_spec(app_spec)
696
+ framework_paths_by_config = target.user_build_configurations.keys.each_with_object({}) do |config, paths_by_config|
697
+ paths_by_config[config] = pod_targets.flat_map do |pod_target|
698
+ spec_paths_to_include = pod_target.library_specs.map(&:name)
699
+ spec_paths_to_include << app_spec.name if pod_target == target
700
+ pod_target.framework_paths.values_at(*spec_paths_to_include).flatten.compact.uniq
701
+ end
702
+ end
703
+ generator = Generator::EmbedFrameworksScript.new(framework_paths_by_config)
704
+ update_changed_file(generator, path)
705
+ add_file_to_support_group(path)
706
+ end
707
+
520
708
  # Manually add `libswiftSwiftOnoneSupport.dylib` as it seems there is an issue with tests that do not include it for Debug configurations.
521
709
  # Possibly related to Swift module optimization.
522
710
  #
@@ -552,35 +740,6 @@ module Pod
552
740
  eos
553
741
  end
554
742
 
555
- # Creates a prefix header file which imports `UIKit` or `Cocoa` according
556
- # to the platform of the target. This file also include any prefix header
557
- # content reported by the specification of the pods.
558
- #
559
- # @param [Pathname] path
560
- # the path to generate the prefix header for.
561
- #
562
- # @param [Array<Sandbox::FileAccessor>] file_accessors
563
- # the file accessors to use for this prefix header that point to a path of a prefix header.
564
- #
565
- # @param [Platform] platform
566
- # the platform to use for this prefix header.
567
- #
568
- # @param [PBXNativeTarget] native_target
569
- # the native target on which the prefix header should be configured for.
570
- #
571
- # @return [void]
572
- #
573
- def create_prefix_header(path, file_accessors, platform, native_target)
574
- generator = Generator::PrefixHeader.new(file_accessors, platform)
575
- update_changed_file(generator, path)
576
- add_file_to_support_group(path)
577
-
578
- relative_path = path.relative_path_from(project.path.dirname)
579
- native_target.build_configurations.each do |c|
580
- c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
581
- end
582
- end
583
-
584
743
  ENABLE_OBJECT_USE_OBJC_FROM = {
585
744
  :ios => Version.new('6'),
586
745
  :osx => Version.new('10.8'),
@@ -615,7 +774,7 @@ module Pod
615
774
  # **Note:** libraries that do *not* specify a platform version are
616
775
  # assumed to have a deployment target of < iOS 6.0 or OS X 10.8.
617
776
  #
618
- # For more information, see: http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
777
+ # For more information, see: https://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
619
778
  #
620
779
  # @param [Specification::Consumer] consumer
621
780
  # The consumer for the specification for which the compiler flags
@@ -640,10 +799,10 @@ module Pod
640
799
  flags * ' '
641
800
  end
642
801
 
643
- def apply_xcconfig_file_ref_to_resource_bundle_targets(resource_bundle_targets, xcconfig_file_ref)
644
- resource_bundle_targets.each do |rsrc_target|
645
- rsrc_target.build_configurations.each do |rsrc_bc|
646
- rsrc_bc.base_configuration_reference = xcconfig_file_ref
802
+ def apply_xcconfig_file_ref_to_targets(targets, xcconfig_file_ref)
803
+ targets.each do |config_target|
804
+ config_target.build_configurations.each do |configuration|
805
+ configuration.base_configuration_reference = xcconfig_file_ref
647
806
  end
648
807
  end
649
808
  end
@@ -654,7 +813,7 @@ module Pod
654
813
  path = target.module_map_path_to_write
655
814
  UI.message "- Copying module map file to #{UI.path(path)}" do
656
815
  contents = custom_module_map.read
657
- unless target.requires_frameworks?
816
+ unless target.build_as_framework?
658
817
  contents.gsub!(/^(\s*)framework\s+(module[^{}]+){/, '\1\2{')
659
818
  end
660
819
  generator = Generator::Constant.new(contents)
@@ -712,7 +871,7 @@ module Pod
712
871
 
713
872
  def add_header(build_file, public_headers, private_headers, native_target)
714
873
  file_ref = build_file.file_ref
715
- acl = if !target.requires_frameworks? # Headers are already rooted at ${PODS_ROOT}/Headers/P*/[pod]/...
874
+ acl = if !target.build_as_framework? # Headers are already rooted at ${PODS_ROOT}/Headers/P*/[pod]/...
716
875
  'Project'
717
876
  elsif public_headers.include?(file_ref.real_path)
718
877
  'Public'
@@ -722,7 +881,7 @@ module Pod
722
881
  'Project'
723
882
  end
724
883
 
725
- if target.requires_frameworks? && header_mappings_dir && acl != 'Project'
884
+ if target.build_as_framework? && header_mappings_dir && acl != 'Project'
726
885
  relative_path = file_ref.real_path.relative_path_from(header_mappings_dir)
727
886
  sub_dir = relative_path.dirname
728
887
  copy_phase_name = "Copy #{sub_dir} #{acl} Headers"
@@ -743,21 +902,17 @@ module Pod
743
902
  project.pod_support_files_group(pod_name, dir)
744
903
  end
745
904
 
746
- # @param [String] name
747
- # The name of the app host.
748
-
749
- # @param [Symbol] test_type
750
- # The test type this Info.plist path is for.
751
- #
752
- # @return [Pathname] The absolute path of the Info.plist to use for an app host.
753
- #
754
- def app_host_info_plist_path_for_test_type(name, test_type)
755
- project.path.dirname.+("#{name}/#{target.app_host_label(test_type)}-Info.plist")
905
+ def test_native_target_from_spec(spec, test_native_targets)
906
+ test_target_label = target.test_target_label(spec)
907
+ test_native_targets.find do |test_native_target|
908
+ test_native_target.name == test_target_label
909
+ end
756
910
  end
757
911
 
758
- def test_native_target_from_spec_consumer(spec_consumer, test_native_targets)
759
- test_native_targets.find do |test_native_target|
760
- test_native_target.name == target.test_target_label(spec_consumer.spec)
912
+ def app_native_target_from_spec(spec, app_native_targets)
913
+ app_target_label = target.app_target_label(spec)
914
+ app_native_targets.find do |app_native_target|
915
+ app_native_target.name == app_target_label
761
916
  end
762
917
  end
763
918
 
@@ -779,7 +934,7 @@ module Pod
779
934
  native_target
780
935
  end
781
936
 
782
- # Adds a shell script phase, intended only for static library targets that contain swift,
937
+ # Adds a shell script phase, intended only for library targets that contain swift,
783
938
  # to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates)
784
939
  # to the built products directory. Additionally, the script phase copies the module map, appending a `.Swift`
785
940
  # submodule that references the (moved) compatibility header. Since the module map has been moved, the umbrella header
@@ -790,7 +945,7 @@ module Pod
790
945
  #
791
946
  # @return [Void]
792
947
  #
793
- def add_swift_static_library_compatibility_header_phase(native_target)
948
+ def add_swift_library_compatibility_header_phase(native_target)
794
949
  if custom_module_map
795
950
  raise Informative, 'Using Swift static libraries with custom module maps is currently not supported. ' \
796
951
  "Please build `#{target.label}` as a framework or remove the custom module map."