Class: FastlaneCore::Simulator::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane_core/simulator.rb

Overview

Use the UDID for the given device when setting the destination Why? Because we might get this error message > The requested device could not be found because multiple devices matched the request.

This happens when you have multiple simulators for a given device type / iOS combination

{ platform:iOS Simulator, id:1685B071-AFB2-4DC1-BE29-8370BA4A6EBD, OS:9.0, name:iPhone 5 }
{ platform:iOS Simulator, id:A141F23B-96B3-491A-8949-813B376C28A7, OS:9.0, name:iPhone 5 }

We don’t want to deal with that, so we just use the UDID

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, udid: nil, os_version: nil, state: nil) ⇒ Device

Returns a new instance of Device.



108
109
110
111
112
113
114
# File 'lib/fastlane_core/simulator.rb', line 108

def initialize(name: nil, udid: nil, os_version: nil, state: nil)
  self.name = name
  self.udid = udid
  self.os_version = os_version
  self.ios_version = os_version
  self.state = state
end

Instance Attribute Details

#ios_versionObject

Preserved for backwards compatibility



105
106
107
# File 'lib/fastlane_core/simulator.rb', line 105

def ios_version
  @ios_version
end

#nameObject

Returns the value of attribute name.



102
103
104
# File 'lib/fastlane_core/simulator.rb', line 102

def name
  @name
end

#os_versionObject

Returns the value of attribute os_version.



104
105
106
# File 'lib/fastlane_core/simulator.rb', line 104

def os_version
  @os_version
end

#stateObject

Returns the value of attribute state.



106
107
108
# File 'lib/fastlane_core/simulator.rb', line 106

def state
  @state
end

#udidObject

Returns the value of attribute udid.



103
104
105
# File 'lib/fastlane_core/simulator.rb', line 103

def udid
  @udid
end

Instance Method Details

#resetObject



120
121
122
123
124
125
# File 'lib/fastlane_core/simulator.rb', line 120

def reset
  UI.message("Resetting #{self}")
  `xcrun simctl shutdown #{self.udid}` if self.state == "Booted"
  `xcrun simctl erase #{self.udid}`
  return
end

#to_sObject



116
117
118
# File 'lib/fastlane_core/simulator.rb', line 116

def to_s
  self.name
end