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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 41 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
37 38 39 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 37 def self.description 'Prepares simulator for tests' end |
.is_supported?(platform) ⇒ Boolean
57 58 59 |
# File 'lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb', line 57 def self.is_supported?(platform) true 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 29 30 31 |
# 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_with_brackets = params[:device][version_regex] device_name = params[:device].sub(version_regex, '').strip udid = nil if ios_version_with_brackets.nil? sim = simulators.filter { |d| d.name == params[:device] }.max_by(&:os_version) ios_version_with_brackets = "(#{sim.os_version})" if sim else ios_version = ios_version_with_brackets.delete('()') sim = simulators.detect { |d| "#{d.name} (#{d.os_version})" == params[:device] } udid = `xcrun simctl create '#{device_name}' '#{device_name}' 'iOS#{ios_version}'`.to_s.strip if sim.nil? end udid = sim.udid.to_s.strip unless sim.nil? if sim.nil? && (udid.nil? || udid.empty?) 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 sim && params[:reset] sh("xcrun simctl bootstatus #{udid} -b") UI.success("Simulator #{device_name} #{ios_version_with_brackets} is ready") udid end |