Class: FastlaneCore::DeviceManager::Device

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/device_manager.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_type: nil, os_version: nil, state: nil, is_simulator: nil) ⇒ Device

Returns a new instance of Device.



188
189
190
191
192
193
194
195
196
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 188

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

Instance Attribute Details

#ios_versionObject

Preserved for backwards compatibility



184
185
186
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 184

def ios_version
  @ios_version
end

#is_simulatorObject

Returns the value of attribute is_simulator.



186
187
188
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 186

def is_simulator
  @is_simulator
end

#nameObject

Returns the value of attribute name.



180
181
182
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 180

def name
  @name
end

#os_typeObject

Returns the value of attribute os_type.



182
183
184
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 182

def os_type
  @os_type
end

#os_versionObject

Returns the value of attribute os_version.



183
184
185
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 183

def os_version
  @os_version
end

#stateObject

Returns the value of attribute state.



185
186
187
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 185

def state
  @state
end

#udidObject

Returns the value of attribute udid.



181
182
183
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 181

def udid
  @udid
end

Instance Method Details

#deleteObject



209
210
211
212
213
214
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 209

def delete
  UI.message("Deleting #{self}")
  `xcrun simctl shutdown #{self.udid}` unless self.state == "Shutdown"
  `xcrun simctl delete #{self.udid}`
  return
end

#disable_slide_to_typeObject



216
217
218
219
220
221
222
223
224
225
226
227
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 216

def disable_slide_to_type
  return unless is_simulator
  return unless os_type == "iOS"
  return unless Gem::Version.new(os_version) >= Gem::Version.new('13.0')
  UI.message("Disabling 'Slide to Type' #{self}")

  plist_buddy = '/usr/libexec/PlistBuddy'
  plist_buddy_cmd = "-c \"Add :KeyboardContinuousPathEnabled bool false\""
  plist_path = File.expand_path("~/Library/Developer/CoreSimulator/Devices/#{self.udid}/data/Library/Preferences/com.apple.keyboard.ContinuousPath.plist")

  Helper.backticks("#{plist_buddy} #{plist_buddy_cmd} #{plist_path} >/dev/null 2>&1")
end

#resetObject



202
203
204
205
206
207
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 202

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

#to_sObject



198
199
200
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 198

def to_s
  self.name
end