cocoapods 1.9.0.beta.3 → 1.10.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +222 -0
  3. data/README.md +2 -1
  4. data/lib/cocoapods.rb +3 -1
  5. data/lib/cocoapods/command.rb +12 -2
  6. data/lib/cocoapods/command/lib/lint.rb +12 -3
  7. data/lib/cocoapods/command/repo/push.rb +1 -1
  8. data/lib/cocoapods/command/repo/update.rb +11 -0
  9. data/lib/cocoapods/command/spec/lint.rb +12 -3
  10. data/lib/cocoapods/config.rb +17 -0
  11. data/lib/cocoapods/downloader/cache.rb +2 -2
  12. data/lib/cocoapods/gem_version.rb +1 -1
  13. data/lib/cocoapods/generator/app_target_helper.rb +10 -2
  14. data/lib/cocoapods/generator/copy_dsyms_script.rb +56 -0
  15. data/lib/cocoapods/generator/copy_resources_script.rb +2 -14
  16. data/lib/cocoapods/generator/copy_xcframework_script.rb +245 -0
  17. data/lib/cocoapods/generator/embed_frameworks_script.rb +137 -206
  18. data/lib/cocoapods/generator/script_phase_constants.rb +99 -0
  19. data/lib/cocoapods/installer.rb +70 -3
  20. data/lib/cocoapods/installer/analyzer.rb +17 -8
  21. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +1 -1
  22. data/lib/cocoapods/installer/base_install_hooks_context.rb +135 -0
  23. data/lib/cocoapods/installer/installation_options.rb +5 -0
  24. data/lib/cocoapods/installer/pod_source_installer.rb +2 -1
  25. data/lib/cocoapods/installer/post_install_hooks_context.rb +1 -127
  26. data/lib/cocoapods/installer/post_integrate_hooks_context.rb +9 -0
  27. data/lib/cocoapods/installer/sandbox_dir_cleaner.rb +2 -1
  28. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +132 -111
  29. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +45 -6
  30. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +13 -27
  31. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +2 -1
  32. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +4 -4
  33. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +175 -58
  34. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +61 -30
  35. data/lib/cocoapods/installer/xcode/pods_project_generator/project_generator.rb +3 -2
  36. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +5 -7
  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/sources_manager.rb +2 -1
  40. data/lib/cocoapods/target.rb +44 -2
  41. data/lib/cocoapods/target/aggregate_target.rb +35 -0
  42. data/lib/cocoapods/target/build_settings.rb +86 -19
  43. data/lib/cocoapods/target/pod_target.rb +85 -11
  44. data/lib/cocoapods/user_interface/error_report.rb +1 -1
  45. data/lib/cocoapods/user_interface/inspector_reporter.rb +3 -10
  46. data/lib/cocoapods/validator.rb +32 -8
  47. data/lib/cocoapods/xcode/framework_paths.rb +1 -1
  48. data/lib/cocoapods/xcode/xcframework.rb +17 -4
  49. data/lib/cocoapods/xcode/xcframework/xcframework_slice.rb +81 -3
  50. metadata +30 -38
  51. data/lib/cocoapods/generator/prepare_artifacts_script.rb +0 -244
@@ -90,7 +90,8 @@ module Pod
90
90
  #
91
91
  def lock_files!(file_accessors)
92
92
  return if local?
93
- FileUtils.chmod('u-w', source_files(file_accessors))
93
+ unlocked_files = source_files(file_accessors).reject { |f| (File.stat(f).mode & 0o200).zero? }
94
+ FileUtils.chmod('u-w', unlocked_files)
94
95
  end
95
96
 
96
97
  # Unlocks the source files if appropriate.
@@ -3,133 +3,7 @@ module Pod
3
3
  # Context object designed to be used with the HooksManager which describes
4
4
  # the context of the installer.
5
5
  #
6
- class PostInstallHooksContext
7
- # @return [Sandbox] The Sandbox for the project.
8
- #
9
- attr_reader :sandbox
10
-
11
- # @return [String] The path to the sandbox root (`Pods` directory).
12
- #
13
- attr_reader :sandbox_root
14
-
15
- # @return [Xcodeproj::Project] The Pods Xcode project.
16
- #
17
- attr_reader :pods_project
18
-
19
- # @return [Array<UmbrellaTargetDescription>] The list of
20
- # the CocoaPods umbrella targets generated by the installer.
21
- #
22
- attr_reader :umbrella_targets
23
-
24
- # Initialize a new instance
25
- #
26
- # @param [Sandbox] sandbox see #sandbox
27
- # @param [String] sandbox_root see #sandbox_root
28
- # @param [Xcodeproj::Project] pods_project see #pods_project
29
- # @param [Array<UmbrellaTargetDescription>] umbrella_targets see #umbrella_targets
30
- #
31
- def initialize(sandbox, sandbox_root, pods_project, umbrella_targets)
32
- @sandbox = sandbox
33
- @sandbox_root = sandbox_root
34
- @pods_project = pods_project
35
- @umbrella_targets = umbrella_targets
36
- end
37
-
38
- # @return [PostInstallHooksContext] Convenience class generator method
39
- #
40
- # @param [Sandbox] sandbox
41
- # The sandbox
42
- #
43
- # @param [Project] pods_project
44
- # The pods project.
45
- #
46
- # @param [Array<AggregateTarget>] aggregate_targets
47
- # The aggregate targets, which will been presented by an adequate
48
- # {UmbrellaTargetDescription} in the generated context.
49
- #
50
- # @return [HooksContext] Convenience class method to generate the
51
- # static context.
52
- #
53
- def self.generate(sandbox, pods_project, aggregate_targets)
54
- umbrella_targets_descriptions = aggregate_targets.map do |umbrella|
55
- user_project = umbrella.user_project
56
- user_targets = umbrella.user_targets
57
- specs = umbrella.specs
58
- platform_name = umbrella.platform.name
59
- platform_deployment_target = umbrella.platform.deployment_target.to_s
60
- cocoapods_target_label = umbrella.label
61
- UmbrellaTargetDescription.new(user_project, user_targets, specs, platform_name, platform_deployment_target, cocoapods_target_label)
62
- end
63
-
64
- new(sandbox, sandbox.root.to_s, pods_project, umbrella_targets_descriptions)
65
- end
66
-
67
- # Pure data class which describes an umbrella target.
68
- #
69
- class UmbrellaTargetDescription
70
- # @return [Xcodeproj::Project] The user project into which this target
71
- # is integrated.
72
- #
73
- attr_reader :user_project
74
-
75
- # @return [Array<PBXNativeTarget>]
76
- # The list of user targets integrated by this umbrella target.
77
- #
78
- attr_reader :user_targets
79
-
80
- # @return [Array<Specification>] The list of the
81
- # specifications of the target.
82
- #
83
- attr_reader :specs
84
-
85
- # @return [Symbol] The platform (either `:ios`, `:watchos`, `:tvos`, or `:osx`).
86
- #
87
- attr_reader :platform_name
88
-
89
- # @return [String] The deployment target.
90
- #
91
- attr_reader :platform_deployment_target
92
-
93
- # @return [String] The label for the target.
94
- #
95
- attr_reader :cocoapods_target_label
96
-
97
- # Initialize a new instance
98
- #
99
- # @param [Xcodeproj::Project] user_project see #user_project
100
- # @param [Array<PBXNativeTarget>] user_targets see #user_targets
101
- # @param [Array<Specification>] specs see #specs
102
- # @param [Symbol] platform_name see #platform_name
103
- # @param [String] platform_deployment_target see #platform_deployment_target
104
- # @param [String] cocoapods_target_label see #cocoapods_target_label
105
- #
106
- def initialize(user_project, user_targets, specs, platform_name, platform_deployment_target, cocoapods_target_label)
107
- @user_project = user_project
108
- @user_targets = user_targets
109
- @specs = specs
110
- @platform_name = platform_name
111
- @platform_deployment_target = platform_deployment_target
112
- @cocoapods_target_label = cocoapods_target_label
113
- end
114
-
115
- # @return [String] The path of the user project
116
- # integrated by this target.
117
- #
118
- def user_project_path
119
- user_project.path if user_project
120
- end
121
-
122
- # @return [Array<String>] The list of the UUIDs of the
123
- # user targets integrated by this umbrella
124
- # target. They can be used to find the
125
- # targets opening the project They can be used
126
- # to find the targets opening the project with
127
- # Xcodeproj.
128
- #
129
- def user_target_uuids
130
- user_targets.map(&:uuid)
131
- end
132
- end
6
+ class PostInstallHooksContext < BaseInstallHooksContext
133
7
  end
134
8
  end
135
9
  end
@@ -0,0 +1,9 @@
1
+ module Pod
2
+ class Installer
3
+ # Context object designed to be used with the HooksManager which describes
4
+ # the context of the installer.
5
+ #
6
+ class PostIntegrateHooksContext < BaseInstallHooksContext
7
+ end
8
+ end
9
+ end
@@ -67,8 +67,9 @@ module Pod
67
67
  sandbox.pod_target_project_path(pod_target.project_name)
68
68
  end
69
69
  project_dir_names = sandbox_project_dir_names - [sandbox.project_path]
70
+ user_project_dir_names = aggregate_targets.map(&:user_project_path).uniq
70
71
 
71
- removed_project_dir_names = project_dir_names - project_dir_names_to_install
72
+ removed_project_dir_names = project_dir_names - user_project_dir_names - project_dir_names_to_install
72
73
  removed_project_dir_names.each { |dir| remove_dir(dir) }
73
74
  end
74
75
  end
@@ -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