Sha256: 3c2751c4084a61f0134b348341dbd19343a77dea84590975ab464f8659722eff
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
module Fastlane module Helper class SimctlHelper def self.execute_with_simulator_ready(block, runtime, type) device = create_device(runtime, type) device.launch device.wait(90) do |d| Fastlane::UI.message("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 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.message("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 def self.delete_device(device) if device.state != :shutdown device.shutdown device.kill device.wait do |d| Fastlane::UI.message("Waiting for simulator `#{d.name}` to be shutdown") d.state == :shutdown end end Fastlane::UI.message("Deleting simulator `#{device.name}`") device.delete end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fastlane-plugin-simctl-0.1.0 | lib/fastlane/plugin/simctl/helper/simctl_helper.rb |