Skip to content

Commit

Permalink
[Fastlane.swift] fix Unexpected duplicate tasks error message (#21621) (
Browse files Browse the repository at this point in the history
fixes #20104)
  • Loading branch information
mollyIV committed Dec 14, 2023
1 parent 3d51313 commit dc0c66c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fastlane/lib/fastlane/swift_runner_upgrader.rb
Expand Up @@ -232,16 +232,19 @@ def add_missing_flags!(dry_run: false)
# adds new copy files build phase to fastlane_runner_target
def add_missing_copy_phase!(dry_run: false)
# Check if upgrade is needed
# If fastlane copy files build phase exists already, we don't need any more changes to the Xcode project
phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.select { |phase_copy| phase_copy.name == "FastlaneRunnerCopySigned" }.first

old_phase_copy_sign = self.fastlane_runner_target.shell_script_build_phases.select { |phase_copy| phase_copy.shell_script == "cd \"${SRCROOT}\"\ncd ../..\ncp \"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\" .\n" }.first
# Check if Copy Files build phase contains FastlaneRunner target.
phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.map(&:files).flatten.select { |file| file.display_name == "FastlaneRunner" }.first

# If fastlane copy files build phase exists already, we don't need any more changes to the Xcode project
phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.select { |phase_copy| phase_copy.name == "FastlaneRunnerCopySigned" }.first unless phase_copy_sign

return true if dry_run && phase_copy_sign.nil?

return false if dry_run

# Proceed to upgrade
old_phase_copy_sign = self.fastlane_runner_target.shell_script_build_phases.select { |phase_copy| phase_copy.shell_script == "cd \"${SRCROOT}\"\ncd ../..\ncp \"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\" .\n" }.first
old_phase_copy_sign.remove_from_project unless old_phase_copy_sign.nil?

unless phase_copy_sign
Expand Down

0 comments on commit dc0c66c

Please sign in to comment.