Class: FastlaneCore::Simulator
- Inherits:
-
Object
- Object
- FastlaneCore::Simulator
- Defined in:
- lib/fastlane_core/simulator.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Device
Class Method Summary collapse
- .all ⇒ Object
- .clear_cache ⇒ Object
- .requested_os_type ⇒ Object
-
.reset(udid: nil, name: nil, os_version: nil) ⇒ Object
Reset simulator by UDID or name and OS version Latter is useful when combined with -destination option of xcodebuild.
-
.reset_all ⇒ Object
Reset all simulators of this type.
Class Method Details
.all ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fastlane_core/simulator.rb', line 10 def all UI.("Fetching available devices") if $verbose @devices = [] os_type = 'unknown' os_version = 'unknown' output = '' Open3.popen3('xcrun simctl list devices') do |stdin, stdout, stderr, wait_thr| output = stdout.read end unless output.include?("== Devices ==") UI.error("xcrun simctl CLI broken, run `xcrun simctl list devices` and make sure it works") UI.user_error!("xcrun simctl not working.") end output.split(/\n/).each do |line| next if line =~ /^== / if line =~ /^-- / (os_type, os_version) = line.gsub(/-- (.*) --/, '\1').split else # iPad 2 (0EDE6AFC-3767-425A-9658-AAA30A60F212) (Shutdown) # iPad Air 2 (4F3B8059-03FD-4D72-99C0-6E9BBEE2A9CE) (Shutdown) (unavailable, device type profile not found) match = line.match(/\s+([^\(]+) \(([-0-9A-F]+)\) \(([^\(]+)\)(.*unavailable.*)?/) if match && !match[4] && os_type == requested_os_type @devices << Device.new(name: match[1], os_version: os_version, udid: match[2], state: match[3]) end end end return @devices end |
.clear_cache ⇒ Object
43 44 45 |
# File 'lib/fastlane_core/simulator.rb', line 43 def clear_cache @devices = nil end |
.requested_os_type ⇒ Object
6 7 8 |
# File 'lib/fastlane_core/simulator.rb', line 6 def requested_os_type 'iOS' end |
.reset(udid: nil, name: nil, os_version: nil) ⇒ Object
Reset simulator by UDID or name and OS version Latter is useful when combined with -destination option of xcodebuild
54 55 56 57 |
# File 'lib/fastlane_core/simulator.rb', line 54 def reset(udid: nil, name: nil, os_version: nil) match = all.detect { |device| device.udid == udid || device.name == name && device.os_version == os_version } match.reset if match end |
.reset_all ⇒ Object
Reset all simulators of this type
48 49 50 |
# File 'lib/fastlane_core/simulator.rb', line 48 def reset_all all.each(&:reset) end |