Class: Fastlane::Actions::ResetSimulatorContentsAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/reset_simulator_contents.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.aliasesObject



54
55
56
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 54

def self.aliases
  ["reset_simulators"]
end

.authorsObject



66
67
68
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 66

def self.authors
  ["danramteke"]
end

.available_optionsObject



42
43
44
45
46
47
48
49
50
51
52
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 42

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ios,
                                 short_option: "-i",
                                 env_name: "FASTLANE_RESET_SIMULATOR_VERSIONS",
                                 description: "Which versions of Simulators you want to reset content and settings, this does not remove/recreate the simulators",
                                 is_string: false,
                                 optional: true,
                                 type: Array)
  ]
end

.categoryObject



80
81
82
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 80

def self.category
  :misc
end

.descriptionObject



38
39
40
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 38

def self.description
  "Shutdown and reset running simulators"
end

.example_codeObject



74
75
76
77
78
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 74

def self.example_code
  [
    'reset_simulator_contents'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



70
71
72
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 70

def self.is_supported?(platform)
  platform == :ios
end

.outputObject



58
59
60
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 58

def self.output
  nil
end

.reset_up_to_xcode8(ios_versions) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 26

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
  UI.success('Simulators reset')
end

.reset_xcode9_and_higher(ios_versions) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 14

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

.return_valueObject



62
63
64
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 62

def self.return_value
  nil
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'fastlane/lib/fastlane/actions/reset_simulator_contents.rb', line 4

def self.run(params)
  ios_versions = params[:ios]

  if Helper.xcode_at_least?("9")
    reset_xcode9_and_higher(ios_versions)
  else
    reset_up_to_xcode8(ios_versions)
  end
end