Class: Fastlane::Helper::SimctlHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::SimctlHelper
- Defined in:
- lib/fastlane/plugin/simctl/helper/simctl_helper.rb
Class Method Summary collapse
- .create_device(runtime, type) ⇒ Object
- .delete_device(device) ⇒ Object
- .execute_with_simulator_ready(block, runtime, type) ⇒ Object
Class Method Details
.create_device(runtime, type) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fastlane/plugin/simctl/helper/simctl_helper.rb', line 20 def self.create_device(runtime, type) runtime = if runtime.eql? 'latest' SimCtl::Runtime.latest('ios') else SimCtl.runtime(name: runtime) end device_type = SimCtl.devicetype(name: type) device_name = type.to_s device_name += "-#{ENV['JOB_NAME']}" if ENV['JOB_NAME'] device_name += "@#{ENV['BUILD_NUMBER']}" if ENV['BUILD_NUMBER'] Fastlane::UI.("Starting simulator with runtime: `#{runtime.name}`, device type: `#{device_type.name}`"\ " and device name: `#{device_name}`") SimCtl.reset_device(device_name, device_type, runtime) end |
.delete_device(device) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fastlane/plugin/simctl/helper/simctl_helper.rb', line 35 def self.delete_device(device) if device.state != :shutdown device.shutdown device.kill device.wait do |d| Fastlane::UI.("Waiting for simulator `#{d.name}` to be shutdown") d.state == :shutdown end end Fastlane::UI.("Deleting simulator `#{device.name}`") device.delete end |
.execute_with_simulator_ready(block, runtime, type) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fastlane/plugin/simctl/helper/simctl_helper.rb', line 4 def self.execute_with_simulator_ready(block, runtime, type) device = create_device(runtime, type) device.launch device.wait(90) do |d| Fastlane::UI.("Waiting for simulator `#{d.name}` to be ready") d.state == :booted && d.ready? end begin block.call(device) rescue StandardError => error throw error ensure delete_device(device) end end |