Class: Fastlane::Actions::PrepareSimulatorAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::PrepareSimulatorAction
- Defined in:
- lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb
Documentation collapse
Class Method Summary collapse
Class Method Details
.available_options ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 38 def self. [ FastlaneCore::ConfigItem.new( key: :device, description: 'Simulator name or name with version', is_string: false ), FastlaneCore::ConfigItem.new( key: :reset, description: 'Reset simulator contents', optional: true, is_string: false ) ] end |
.description ⇒ Object
34 35 36 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 34 def self.description 'Prepares simulator for tests' end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 4 def self.run(params) simulators = FastlaneCore::Simulator.all version_regex = /\((\d+\.)?(\d+\.)?(\*|\d+)\)/ ios_version = params[:device][version_regex] if ios_version.nil? sim = simulators.filter { |d| d.name == params[:device] }.max_by(&:os_version) else sim = simulators.detect { |d| "#{d.name} (#{d.os_version})" == params[:device] } if sim.nil? device_name = params[:device].sub(version_regex, '').strip sh("xcrun simctl create '#{device_name}' '#{device_name}' 'iOS#{ios_version.delete('()')}'") sim = simulators.detect { |d| "#{d.name} (#{d.os_version})" == params[:device] } end end if sim.nil? simulators.map! { |d| "#{d.name} (#{d.os_version})" }.join("\n") UI.user_error!("Simulator #{params[:device]} not found \nAvailable simulators: \n#{simulators}") end sim.reset if params[:reset] sh("xcrun simctl bootstatus #{sim.udid} -b") UI.success("Simulator #{sim.name} (#{sim.os_version}) is ready") end |
.supported?(_platform) ⇒ Boolean
54 55 56 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 54 def self.supported?(_platform) true end |