fastlane/lib/fastlane/actions/reset_simulator_contents.rb in fastlane-2.99.1 vs fastlane/lib/fastlane/actions/reset_simulator_contents.rb in fastlane-2.100.0

- old
+ new

@@ -1,15 +1,33 @@ module Fastlane module Actions class ResetSimulatorContentsAction < Action def self.run(params) + ios_versions = params[:ios] + if Helper.xcode_at_least?("9") - UI.important("Resetting simulators currently doesn't work with Xcode 9, stay tuned as we are working to add support for all new tools.") - return + reset_xcode9_and_higher(ios_versions) + else + reset_up_to_xcode8(ios_versions) end + end - if params[:ios] - params[:ios].each do |os_version| + def self.reset_xcode9_and_higher(ios_versions) + UI.verbose("Resetting simulator contents for Xcode 9 and later") + simulators = FastlaneCore::DeviceManager.simulators('iOS') + if ios_versions + simulators.select! { |s| ios_versions.include?(s.os_version) } + end + simulators.each do |simulator| + FastlaneCore::Simulator.reset(udid: simulator.udid) + end + UI.success('Simulators reset') + end + + def self.reset_up_to_xcode8(ios_versions) + UI.verbose("Resetting simulator contents for Xcode 8 and earlier") + if ios_versions + ios_versions.each do |os_version| FastlaneCore::Simulator.reset_all_by_version(os_version: os_version) end else FastlaneCore::Simulator.reset_all end