cocoapods 1.9.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +245 -5
  3. data/README.md +2 -1
  4. data/lib/cocoapods/command/lib/lint.rb +12 -3
  5. data/lib/cocoapods/command/repo/push.rb +1 -1
  6. data/lib/cocoapods/command/repo/update.rb +11 -0
  7. data/lib/cocoapods/command/spec/lint.rb +12 -3
  8. data/lib/cocoapods/command.rb +12 -2
  9. data/lib/cocoapods/config.rb +17 -0
  10. data/lib/cocoapods/downloader/cache.rb +2 -2
  11. data/lib/cocoapods/gem_version.rb +1 -1
  12. data/lib/cocoapods/generator/app_target_helper.rb +10 -2
  13. data/lib/cocoapods/generator/copy_dsyms_script.rb +56 -0
  14. data/lib/cocoapods/generator/copy_resources_script.rb +2 -14
  15. data/lib/cocoapods/generator/copy_xcframework_script.rb +245 -0
  16. data/lib/cocoapods/generator/embed_frameworks_script.rb +125 -212
  17. data/lib/cocoapods/generator/script_phase_constants.rb +99 -0
  18. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +1 -1
  19. data/lib/cocoapods/installer/analyzer.rb +17 -8
  20. data/lib/cocoapods/installer/base_install_hooks_context.rb +135 -0
  21. data/lib/cocoapods/installer/installation_options.rb +5 -0
  22. data/lib/cocoapods/installer/pod_source_installer.rb +2 -1
  23. data/lib/cocoapods/installer/post_install_hooks_context.rb +1 -127
  24. data/lib/cocoapods/installer/post_integrate_hooks_context.rb +9 -0
  25. data/lib/cocoapods/installer/project_cache/project_metadata_cache.rb +4 -0
  26. data/lib/cocoapods/installer/sandbox_dir_cleaner.rb +2 -1
  27. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +132 -111
  28. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +13 -27
  29. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +5 -1
  30. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +2 -1
  31. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +8 -6
  32. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +180 -59
  33. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +61 -30
  34. data/lib/cocoapods/installer/xcode/pods_project_generator/project_generator.rb +3 -2
  35. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +5 -7
  36. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +45 -6
  37. data/lib/cocoapods/installer/xcode/pods_project_generator_result.rb +19 -0
  38. data/lib/cocoapods/installer/xcode/target_validator.rb +1 -1
  39. data/lib/cocoapods/installer.rb +70 -3
  40. data/lib/cocoapods/sources_manager.rb +2 -1
  41. data/lib/cocoapods/target/aggregate_target.rb +35 -0
  42. data/lib/cocoapods/target/build_settings.rb +94 -18
  43. data/lib/cocoapods/target/pod_target.rb +85 -11
  44. data/lib/cocoapods/target.rb +44 -2
  45. data/lib/cocoapods/user_interface/error_report.rb +1 -1
  46. data/lib/cocoapods/user_interface/inspector_reporter.rb +3 -10
  47. data/lib/cocoapods/validator.rb +37 -11
  48. data/lib/cocoapods/xcode/framework_paths.rb +1 -1
  49. data/lib/cocoapods/xcode/xcframework/xcframework_slice.rb +81 -3
  50. data/lib/cocoapods/xcode/xcframework.rb +17 -4
  51. data/lib/cocoapods.rb +3 -1
  52. metadata +31 -53
  53. data/lib/cocoapods/generator/prepare_artifacts_script.rb +0 -257
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/string/inflections'
2
2
  require 'cocoapods/xcode/framework_paths'
3
+ require 'cocoapods/target/build_settings'
3
4
 
4
5
  module Pod
5
6
  class Installer
@@ -31,27 +32,41 @@ module Pod
31
32
  # For messages extensions, this only applies if it's embedded in a messages
32
33
  # application.
33
34
  #
34
- EMBED_FRAMEWORK_TARGET_TYPES = [:application, :unit_test_bundle, :ui_test_bundle, :watch2_extension, :messages_application].freeze
35
+ EMBED_FRAMEWORK_TARGET_TYPES = [:application, :application_on_demand_install_capable, :unit_test_bundle, :ui_test_bundle, :watch2_extension, :messages_application].freeze
35
36
 
36
37
  # @return [String] the name of the embed frameworks phase
37
38
  #
38
39
  EMBED_FRAMEWORK_PHASE_NAME = 'Embed Pods Frameworks'.freeze
39
40
 
40
- # @return [String] the name of the embed frameworks phase
41
+ # @return [String] the name of the copy xcframeworks phase
41
42
  #
42
- PREPARE_ARTIFACTS_PHASE_NAME = 'Prepare Artifacts'.freeze
43
+ COPY_XCFRAMEWORKS_PHASE_NAME = 'Copy XCFrameworks'.freeze
43
44
 
44
45
  # @return [String] the name of the copy resources phase
45
46
  #
46
47
  COPY_PODS_RESOURCES_PHASE_NAME = 'Copy Pods Resources'.freeze
47
48
 
49
+ # @return [String] the name of the copy dSYM files phase
50
+ #
51
+ COPY_DSYM_FILES_PHASE_NAME = 'Copy dSYMs'.freeze
52
+
48
53
  # @return [Integer] the maximum number of input and output paths to use for a script phase
49
54
  #
50
55
  MAX_INPUT_OUTPUT_PATHS = 1000
51
56
 
52
- # @return [String] the path to the artifact lists file used in the prepare & embed scripts
57
+ # @return [Array<String>] names of script phases that existed in previous versions of CocoaPods
58
+ #
59
+ REMOVED_SCRIPT_PHASE_NAMES = [
60
+ 'Prepare Artifacts'.freeze,
61
+ ].freeze
62
+
63
+ # @return [float] Returns Minimum Xcode Compatibility version for FileLists
53
64
  #
54
- ARTIFACT_LIST_FILE = '${BUILT_PRODUCTS_DIR}/cocoapods-artifacts-${CONFIGURATION}.txt'.freeze
65
+ MIN_FILE_LIST_COMPATIBILITY_VERSION = 9.3
66
+
67
+ # @return [String] Returns Minimum Xcode Object version for FileLists
68
+ #
69
+ MIN_FILE_LIST_OBJECT_VERSION = 50
55
70
 
56
71
  # @return [AggregateTarget] the target that should be integrated.
57
72
  #
@@ -83,7 +98,14 @@ module Pod
83
98
  # should be stored in a file list file.
84
99
  #
85
100
  def input_output_paths_use_filelist?(object)
86
- object.project.object_version.to_i >= 50
101
+ unless object.project.root_object.compatibility_version.nil?
102
+ version_match = object.project.root_object.compatibility_version.match(/Xcode ([0-9]*\.[0-9]*)/).to_a
103
+ end
104
+ if version_match&.at(1).nil?
105
+ object.project.object_version.to_i >= MIN_FILE_LIST_OBJECT_VERSION
106
+ else
107
+ Pod::Version.new(version_match[1]) >= Pod::Version.new(MIN_FILE_LIST_COMPATIBILITY_VERSION)
108
+ end
87
109
  end
88
110
 
89
111
  # Sets the input & output paths for the given script build phase.
@@ -143,8 +165,17 @@ module Pod
143
165
  TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)
144
166
  end
145
167
 
146
- # Adds a shell script build phase responsible to copy xcframeworks slices
147
- # generated by the TargetDefinition to the build directory.
168
+ # Delete a 'Embed Pods Frameworks' Script Build Phase if present
169
+ #
170
+ # @param [PBXNativeTarget] native_target
171
+ # The native target to remove the script phase from.
172
+ #
173
+ def remove_embed_frameworks_script_phase_from_target(native_target)
174
+ remove_script_phase_from_target(native_target, EMBED_FRAMEWORK_PHASE_NAME)
175
+ end
176
+
177
+ # Adds a shell script build phase responsible to copy the xcframework slice
178
+ # to the intermediate build directory.
148
179
  #
149
180
  # @param [PBXNativeTarget] native_target
150
181
  # The native target to add the script phase into.
@@ -160,31 +191,30 @@ module Pod
160
191
  #
161
192
  # @return [void]
162
193
  #
163
- def create_or_update_prepare_artifacts_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})
164
- phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + PREPARE_ARTIFACTS_PHASE_NAME)
194
+ def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})
195
+ phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME)
165
196
  phase.shell_script = %("#{script_path}"\n)
166
- reorder_script_phase(native_target, phase, :before_compile)
167
197
  TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)
198
+ reorder_script_phase(native_target, phase, :before_compile)
168
199
  end
169
200
 
170
- # Delete a 'Embed Pods Frameworks' Copy Files Build Phase if present
201
+ # Delete a 'Copy XCFrameworks' Script Build Phase if present
171
202
  #
172
203
  # @param [PBXNativeTarget] native_target
173
204
  # The native target to remove the script phase from.
174
205
  #
175
- def remove_embed_frameworks_script_phase_from_target(native_target)
176
- remove_script_phase_from_target(native_target, EMBED_FRAMEWORK_PHASE_NAME)
206
+ def remove_copy_xcframeworks_script_phase_from_target(native_target)
207
+ remove_script_phase_from_target(native_target, COPY_XCFRAMEWORKS_PHASE_NAME)
177
208
  end
178
209
 
179
- # Delete a 'Embed Pods Frameworks' Copy Files Build Phase if present
210
+ # Removes a script phase from a native target by name
180
211
  #
181
212
  # @param [PBXNativeTarget] native_target
182
- # The native target to remove the script phase from.
213
+ # The target from which the script phased should be removed
214
+ #
215
+ # @param [String] phase_name
216
+ # The name of the script phase to remove
183
217
  #
184
- def remove_prepare_artifacts_script_phase_from_target(native_target)
185
- remove_script_phase_from_target(native_target, PREPARE_ARTIFACTS_PHASE_NAME)
186
- end
187
-
188
218
  def remove_script_phase_from_target(native_target, phase_name)
189
219
  build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(phase_name) }
190
220
  return unless build_phase.present?
@@ -239,7 +269,7 @@ module Pod
239
269
  # The value to set for show environment variables in the log during execution of this script phase or
240
270
  # `nil` for not setting the value at all.
241
271
  #
242
- # @return [void]
272
+ # @return [PBXShellScriptBuildPhase] The existing or newly created shell script build phase.
243
273
  #
244
274
  def create_or_update_shell_script_build_phase(native_target, script_phase_name, show_env_vars_in_log = '0')
245
275
  build_phases = native_target.build_phases.grep(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
@@ -263,7 +293,9 @@ module Pod
263
293
  def create_or_update_user_script_phases(script_phases, native_target)
264
294
  script_phase_names = script_phases.map { |k| k[:name] }
265
295
  # Delete script phases no longer present in the target.
266
- native_target_script_phases = native_target.shell_script_build_phases.select { |bp| !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX) }
296
+ native_target_script_phases = native_target.shell_script_build_phases.select do |bp|
297
+ !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX)
298
+ end
267
299
  native_target_script_phases.each do |script_phase|
268
300
  script_phase_name_without_prefix = script_phase.name.sub(USER_BUILD_PHASE_PREFIX, '')
269
301
  unless script_phase_names.include?(script_phase_name_without_prefix)
@@ -293,18 +325,27 @@ module Pod
293
325
  end
294
326
 
295
327
  def reorder_script_phase(native_target, script_phase, execution_position)
296
- return if execution_position == :any
297
- compile_build_phase_index = native_target.build_phases.index do |bp|
298
- bp.is_a?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
328
+ return if execution_position == :any || execution_position.to_s.empty?
329
+ target_phase_type = Xcodeproj::Project::Object::PBXSourcesBuildPhase
330
+ order_before = case execution_position
331
+ when :before_compile
332
+ true
333
+ when :after_compile
334
+ false
335
+ else
336
+ raise ArgumentError, "Unknown execution position `#{execution_position}`"
337
+ end
338
+
339
+ target_phase_index = native_target.build_phases.index do |bp|
340
+ bp.is_a?(target_phase_type)
299
341
  end
300
- unless compile_build_phase_index.nil?
301
- script_phase_index = native_target.build_phases.index do |bp|
302
- bp.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && !bp.name.nil? && bp.name == script_phase.name
303
- end
304
- if (execution_position == :before_compile && script_phase_index > compile_build_phase_index) ||
305
- (execution_position == :after_compile && script_phase_index < compile_build_phase_index)
306
- native_target.build_phases.move_from(script_phase_index, compile_build_phase_index)
307
- end
342
+ return if target_phase_index.nil?
343
+ script_phase_index = native_target.build_phases.index do |bp|
344
+ bp.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && !bp.name.nil? && bp.name == script_phase.name
345
+ end
346
+ if (order_before && script_phase_index > target_phase_index) ||
347
+ (!order_before && script_phase_index < target_phase_index)
348
+ native_target.build_phases.move_from(script_phase_index, target_phase_index)
308
349
  end
309
350
  end
310
351
 
@@ -327,27 +368,6 @@ module Pod
327
368
  end
328
369
  end
329
370
 
330
- # Returns an extension in the target that corresponds to the
331
- # resource's input extension.
332
- #
333
- # @param [String] input_extension
334
- # The input extension to map to.
335
- #
336
- # @return [String] The output extension.
337
- #
338
- def output_extension_for_resource(input_extension)
339
- case input_extension
340
- when '.storyboard' then '.storyboardc'
341
- when '.xib' then '.nib'
342
- when '.framework' then '.framework'
343
- when '.xcdatamodel' then '.mom'
344
- when '.xcdatamodeld' then '.momd'
345
- when '.xcmappingmodel' then '.cdm'
346
- when '.xcassets' then '.car'
347
- else input_extension
348
- end
349
- end
350
-
351
371
  # Returns the resource output paths for all given input paths.
352
372
  #
353
373
  # @param [Array<String>] resource_input_paths
@@ -360,31 +380,51 @@ module Pod
360
380
  base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'
361
381
  extname = File.extname(resource_input_path)
362
382
  basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path)
363
- output_extension = TargetIntegrator.output_extension_for_resource(extname)
383
+ output_extension = Target.output_extension_for_resource(extname)
364
384
  File.join(base_path, File.basename(basename, extname) + output_extension)
365
385
  end.uniq
366
386
  end
367
387
 
368
- # Returns the framework output paths for the given input paths
388
+ # Returns the framework input paths for the given framework paths
369
389
  #
370
- # @param [Array<Xcode::FrameworkPaths>] framework_input_paths
390
+ # @param [Hash<Array<Xcode::FrameworkPaths>>] framework_paths
391
+ # The target's framework paths to map to input paths.
392
+ #
393
+ # @param [Hash<Array<XCFramework>>] xcframeworks
394
+ # The target's xcframeworks to map to input paths.
395
+ #
396
+ # @return [Array<String>] The embed frameworks script input paths
397
+ #
398
+ def embed_frameworks_input_paths(framework_paths, xcframeworks)
399
+ input_paths = framework_paths.map(&:source_path)
400
+ # Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices
401
+ xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.each do |xcframework|
402
+ name = xcframework.name
403
+ input_paths << "#{Pod::Target::BuildSettings.xcframework_intermediate_dir(xcframework)}/#{name}.framework/#{name}"
404
+ end
405
+ input_paths
406
+ end
407
+
408
+ # Returns the framework output paths for the given framework paths
409
+ #
410
+ # @param [Array<Xcode::FrameworkPaths>] framework_paths
371
411
  # The framework input paths to map to output paths.
372
412
  #
373
- # @return [Array<String>] The framework output paths
374
- #
375
- def framework_output_paths(framework_input_paths)
376
- framework_input_paths.flat_map do |framework_path|
377
- framework_output_path = "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}"
378
- dsym_output_path = if (dsym_input_path = framework_path.dsym_path)
379
- "${DWARF_DSYM_FOLDER_PATH}/#{File.basename(dsym_input_path)}"
380
- end
381
- bcsymbol_output_paths = unless framework_path.bcsymbolmap_paths.nil?
382
- framework_path.bcsymbolmap_paths.map do |bcsymbolmap_path|
383
- "${BUILT_PRODUCTS_DIR}/#{File.basename(bcsymbolmap_path)}"
384
- end
385
- end
386
- [framework_output_path, dsym_output_path, *bcsymbol_output_paths]
387
- end.compact.uniq
413
+ # @param [Array<XCFramework>] xcframeworks
414
+ # The installed xcframeworks.
415
+ #
416
+ # @return [Array<String>] The embed framework script output paths
417
+ #
418
+ def embed_frameworks_output_paths(framework_paths, xcframeworks)
419
+ paths = framework_paths.map do |framework_path|
420
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}"
421
+ end.uniq
422
+ # Static xcframeworks are not copied to the build dir
423
+ # so only include dynamic artifacts that will be copied to the build folder
424
+ xcframework_paths = xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.map do |xcframework|
425
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{xcframework.name}.framework"
426
+ end
427
+ paths + xcframework_paths
388
428
  end
389
429
  end
390
430
 
@@ -398,9 +438,9 @@ module Pod
398
438
  UI.section(integration_message) do
399
439
  XCConfigIntegrator.integrate(target, native_targets)
400
440
 
441
+ remove_obsolete_script_phases
401
442
  add_pods_library
402
443
  add_embed_frameworks_script_phase
403
- add_prepare_artifacts_script_phase
404
444
  remove_embed_frameworks_script_phase_from_embedded_targets
405
445
  add_copy_resources_script_phase
406
446
  add_check_manifest_lock_script_phase
@@ -504,7 +544,7 @@ module Pod
504
544
  # @return [void]
505
545
  #
506
546
  def add_embed_frameworks_script_phase
507
- unless target.includes_frameworks? || target.includes_xcframeworks?
547
+ unless target.includes_frameworks? || (target.xcframeworks_by_config.values.flatten.any? { |xcf| xcf.build_type.dynamic_framework? })
508
548
  native_targets_to_embed_in.each do |native_target|
509
549
  TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target)
510
550
  end
@@ -515,16 +555,16 @@ module Pod
515
555
  input_paths_by_config = {}
516
556
  output_paths_by_config = {}
517
557
  if use_input_output_paths?
518
- target.framework_paths_by_config.each do |config, framework_paths|
558
+ configs = Set.new(target.framework_paths_by_config.keys + target.xcframeworks_by_config.keys).sort
559
+ configs.each do |config|
560
+ framework_paths = target.framework_paths_by_config[config] || []
561
+ xcframeworks = target.xcframeworks_by_config[config] || []
562
+
519
563
  input_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_input_files_path(config), target.embed_frameworks_script_input_files_relative_path)
520
- input_paths = input_paths_by_config[input_paths_key] = [script_path]
521
- input_paths << ARTIFACT_LIST_FILE if target.includes_xcframeworks?
522
- framework_paths.each do |path|
523
- input_paths.concat(path.all_paths)
524
- end
564
+ input_paths_by_config[input_paths_key] = [script_path] + TargetIntegrator.embed_frameworks_input_paths(framework_paths, xcframeworks)
525
565
 
526
566
  output_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_output_files_path(config), target.embed_frameworks_script_output_files_relative_path)
527
- output_paths_by_config[output_paths_key] = TargetIntegrator.framework_output_paths(framework_paths)
567
+ output_paths_by_config[output_paths_key] = TargetIntegrator.embed_frameworks_output_paths(framework_paths, xcframeworks)
528
568
  end
529
569
  end
530
570
 
@@ -533,36 +573,6 @@ module Pod
533
573
  end
534
574
  end
535
575
 
536
- # Find or create a 'Prepare Artifacts' Copy Files Build Phase
537
- #
538
- # @return [void]
539
- #
540
- def add_prepare_artifacts_script_phase
541
- unless target.includes_xcframeworks?
542
- native_targets_to_embed_in.each do |native_target|
543
- TargetIntegrator.remove_prepare_artifacts_script_phase_from_target(native_target)
544
- end
545
- return
546
- end
547
-
548
- script_path = target.prepare_artifacts_script_relative_path
549
- input_paths_by_config = {}
550
- output_paths_by_config = {}
551
- if use_input_output_paths?
552
- target.xcframeworks_by_config.each do |config, xcframeworks|
553
- input_paths_key = XCFileListConfigKey.new(target.prepare_artifacts_script_input_files_path(config), target.prepare_artifacts_script_input_files_relative_path)
554
- input_paths = input_paths_by_config[input_paths_key] = [script_path]
555
- input_paths.concat(xcframeworks.map { |xcf| "${PODS_ROOT}/#{xcf.path.relative_path_from(target.sandbox.root)}" })
556
-
557
- output_paths_key = XCFileListConfigKey.new(target.prepare_artifacts_script_output_files_path(config), target.prepare_artifacts_script_output_files_relative_path)
558
- output_paths_by_config[output_paths_key] = [ARTIFACT_LIST_FILE]
559
- end
560
- end
561
- native_targets_to_embed_in.each do |native_target|
562
- TargetIntegrator.create_or_update_prepare_artifacts_script_phase_to_target(native_target, script_path, input_paths_by_config, output_paths_by_config)
563
- end
564
- end
565
-
566
576
  # Updates all target script phases for the current target, including creating or updating, deleting
567
577
  # and re-ordering.
568
578
  #
@@ -603,6 +613,17 @@ module Pod
603
613
  end
604
614
  end
605
615
 
616
+ # @param [Array<String>] removed_phase_names
617
+ # The names of the script phases that should be removed
618
+ #
619
+ def remove_obsolete_script_phases(removed_phase_names = REMOVED_SCRIPT_PHASE_NAMES)
620
+ native_targets.each do |native_target|
621
+ removed_phase_names.each do |phase_name|
622
+ TargetIntegrator.remove_script_phase_from_target(native_target, phase_name)
623
+ end
624
+ end
625
+ end
626
+
606
627
  private
607
628
 
608
629
  # @!group Private Helpers
@@ -6,6 +6,10 @@ module Pod
6
6
  # project and the relative support files.
7
7
  #
8
8
  class AggregateTargetInstaller < TargetInstaller
9
+ # @return [AggregateTarget] @see TargetInstaller#target
10
+ #
11
+ attr_reader :target
12
+
9
13
  # Creates the target in the Pods project and the relative support files.
10
14
  #
11
15
  # @return [TargetInstallationResult] the result of the installation of this target.
@@ -30,8 +34,7 @@ module Pod
30
34
  # cause an App Store rejection because frameworks cannot be
31
35
  # embedded in embedded targets.
32
36
  #
33
- create_embed_frameworks_script if (target.includes_frameworks? || target.includes_xcframeworks?) && !target.requires_host_target?
34
- create_prepare_artifacts_script if target.includes_xcframeworks? && !target.requires_host_target?
37
+ create_embed_frameworks_script if embed_frameworks_script_required?
35
38
  create_bridge_support_file(native_target)
36
39
  create_copy_resources_script if target.includes_resources?
37
40
  create_acknowledgements
@@ -76,6 +79,13 @@ module Pod
76
79
  super.merge(settings)
77
80
  end
78
81
 
82
+ # @return [Boolean] whether this target requires an `Embed Frameworks` script phase
83
+ #
84
+ def embed_frameworks_script_required?
85
+ includes_dynamic_xcframeworks = target.xcframeworks_by_config.values.flatten.map(&:build_type).any?(&:dynamic_framework?)
86
+ (target.includes_frameworks? || includes_dynamic_xcframeworks) && !target.requires_host_target?
87
+ end
88
+
79
89
  # Creates the group that holds the references to the support files
80
90
  # generated by this installer.
81
91
  #
@@ -154,33 +164,9 @@ module Pod
154
164
  #
155
165
  def create_embed_frameworks_script
156
166
  path = target.embed_frameworks_script_path
157
- generator = Generator::EmbedFrameworksScript.new(target.framework_paths_by_config)
158
- update_changed_file(generator, path)
159
- add_file_to_support_group(path)
160
- end
161
-
162
- # Creates a script that prepares artifacts for embedding into a host target.
163
- #
164
- # @note We can't use Xcode default link libraries phase, because
165
- # we need to ensure that we only copy the frameworks which are
166
- # relevant for the current build configuration.
167
- #
168
- # @return [void]
169
- #
170
- def create_prepare_artifacts_script
171
- path = target.prepare_artifacts_script_path
172
- generator = Generator::PrepareArtifactsScript.new(target.xcframeworks_by_config, sandbox.root, target.platform)
167
+ generator = Generator::EmbedFrameworksScript.new(target.framework_paths_by_config, target.xcframeworks_by_config)
173
168
  update_changed_file(generator, path)
174
169
  add_file_to_support_group(path)
175
-
176
- target.user_build_configurations.each_key do |config|
177
- if (input_file_list = target.prepare_artifacts_script_input_files_path(config))
178
- add_file_to_support_group(input_file_list)
179
- end
180
- if (output_file_list = target.prepare_artifacts_script_output_files_path(config))
181
- add_file_to_support_group(output_file_list)
182
- end
183
- end
184
170
  end
185
171
 
186
172
  # Generates the acknowledgement files (markdown and plist) for the target.
@@ -79,7 +79,11 @@ module Pod
79
79
  app_host_target.build_configurations.each do |configuration|
80
80
  configuration.build_settings['PRODUCT_NAME'] = app_target_label
81
81
  configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
82
- configuration.build_settings['CODE_SIGN_IDENTITY'] = '' if platform == :osx
82
+ if platform == :osx
83
+ configuration.build_settings['CODE_SIGN_IDENTITY'] = ''
84
+ elsif platform == :ios
85
+ configuration.build_settings['CODE_SIGN_IDENTITY'] = 'iPhone Developer'
86
+ end
83
87
  configuration.build_settings['CURRENT_PROJECT_VERSION'] = '1'
84
88
  end
85
89
 
@@ -218,7 +218,8 @@ module Pod
218
218
  pod_name = file_accessor.spec.name
219
219
  preserve_pod_file_structure_flag = (sandbox.local?(pod_name) || preserve_pod_file_structure) && reflect_file_system_structure
220
220
  base_path = preserve_pod_file_structure_flag ? common_path(paths) : nil
221
- group = pods_project.group_for_spec(pod_name, group_key)
221
+ actual_group_key = preserve_pod_file_structure_flag ? nil : group_key
222
+ group = pods_project.group_for_spec(pod_name, actual_group_key)
222
223
  paths.each do |path|
223
224
  pods_project.add_file_reference(path, group, preserve_pod_file_structure_flag, base_path)
224
225
  end
@@ -53,8 +53,8 @@ module Pod
53
53
 
54
54
  # Wire up app native targets.
55
55
  unless pod_target_installation_result.app_native_targets.empty?
56
- wire_app_native_targets(pod_target, native_target, pod_target_installation_result,
57
- pod_target_installation_results, project, frameworks_group, metadata_cache)
56
+ wire_app_native_targets(pod_target, pod_target_installation_result, pod_target_installation_results,
57
+ project, frameworks_group, metadata_cache)
58
58
  end
59
59
  end
60
60
  end
@@ -152,15 +152,17 @@ module Pod
152
152
  target_attributes[test_native_target.uuid.to_s] = { 'TestTargetID' => app_native_target.uuid.to_s }
153
153
  project.root_object.attributes['TargetAttributes'] = target_attributes
154
154
  test_native_target.add_dependency(app_native_target)
155
- else
155
+ elsif cached_dependency = metadata_cache.target_label_by_metadata[app_host_target_label]
156
156
  # Hit the cache
157
- cached_dependency = metadata_cache.target_label_by_metadata[app_host_target_label]
158
157
  project.add_cached_subproject_reference(sandbox, cached_dependency, project.dependencies_group)
159
158
  Project.add_cached_dependency(sandbox, test_native_target, cached_dependency)
159
+ else
160
+ raise "Expected to either have an installation or cache result for #{app_host_target_label} (from pod #{app_host_pod_target_label}) " \
161
+ "for target #{test_native_target.name} in project #{project.project_name}"
160
162
  end
161
163
  end
162
164
 
163
- def wire_app_native_targets(pod_target, native_target, installation_result, pod_target_installation_results, project, frameworks_group, metadata_cache)
165
+ def wire_app_native_targets(pod_target, installation_result, pod_target_installation_results, project, frameworks_group, metadata_cache)
164
166
  installation_result.app_specs_by_native_target.each do |app_native_target, app_spec|
165
167
  resource_bundle_native_targets = installation_result.app_resource_bundle_targets[app_spec.name] || []
166
168
  resource_bundle_native_targets.each do |app_resource_bundle_target|
@@ -187,7 +189,7 @@ module Pod
187
189
  # Hit the cache
188
190
  cached_dependency = metadata_cache.target_label_by_metadata[app_dependent_target.label]
189
191
  project.add_cached_pod_subproject(sandbox, cached_dependency, is_local)
190
- Project.add_cached_dependency(sandbox, native_target, cached_dependency)
192
+ Project.add_cached_dependency(sandbox, app_native_target, cached_dependency)
191
193
  end
192
194
  end
193
195
  end