fastlane/lib/fastlane/setup/setup.rb in fastlane_hotfix-2.165.1 vs fastlane/lib/fastlane/setup/setup.rb in fastlane_hotfix-2.187.0

- old
+ new

@@ -33,10 +33,14 @@ # Start the setup process # rubocop:disable Metrics/BlockNesting def self.start(user: nil, is_swift_fastfile: false) if FastlaneCore::FastlaneFolder.setup? && !Helper.test? + + # If Fastfile.swift exists, but the swift sources folder does not, rebuild it + setup_swift_support if is_swift_fastfile + require 'fastlane/lane_list' Fastlane::LaneList.output(FastlaneCore::FastlaneFolder.fastfile_path) UI.important("------------------") UI.important("fastlane is already set up at path `#{FastlaneCore::FastlaneFolder.path}`, see the available lanes above") UI.message("") @@ -125,10 +129,28 @@ end end end # rubocop:enable Metrics/BlockNesting + def self.setup_swift_support + runner_source_resources = "#{Fastlane::ROOT}/swift/." + destination_path = File.expand_path('swift', FastlaneCore::FastlaneFolder.path) + + # Return eearly if already setup + return if File.exist?(destination_path) + + # Show message if Fastfile.swift exists but missing Swift classes and Xcode project + if FastlaneCore::FastlaneFolder.swift? + UI.important("Restoring Swift classes and FastlaneSwiftRunner.xcodeproj...") + end + + FileUtils.cp_r(runner_source_resources, destination_path) + UI.success("Copied Swift fastlane runner project to '#{destination_path}'.") + + Fastlane::SwiftLaneManager.first_time_setup + end + def initialize(is_swift_fastfile: nil, user: nil, project_path: nil, had_multiple_projects_to_choose_from: nil, preferred_setup_method: nil) self.is_swift_fastfile = is_swift_fastfile self.user = user self.project_path = project_path self.had_multiple_projects_to_choose_from = had_multiple_projects_to_choose_from @@ -258,22 +280,13 @@ return gemfile_path end def finish_up write_fastfile! - setup_swift_support if is_swift_fastfile + self.class.setup_swift_support if is_swift_fastfile show_analytics_note explain_concepts suggest_next_steps - end - - def setup_swift_support - runner_source_resources = "#{Fastlane::ROOT}/swift/." - destination_path = File.expand_path('swift', FastlaneCore::FastlaneFolder.path) - FileUtils.cp_r(runner_source_resources, destination_path) - UI.success("Copied Swift fastlane runner project to '#{destination_path}'.") - - Fastlane::SwiftLaneManager.first_time_setup end def fastfile_template_content if self.is_swift_fastfile path = "#{Fastlane::ROOT}/lib/assets/DefaultFastfileTemplate.swift"