Class: FastlaneCore::DeviceManager::Device
- Inherits:
-
Object
- Object
- FastlaneCore::DeviceManager::Device
- 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
-
#ios_version ⇒ Object
Preserved for backwards compatibility.
-
#is_simulator ⇒ Object
Returns the value of attribute is_simulator.
-
#name ⇒ Object
Returns the value of attribute name.
-
#os_type ⇒ Object
Returns the value of attribute os_type.
-
#os_version ⇒ Object
Returns the value of attribute os_version.
-
#state ⇒ Object
Returns the value of attribute state.
-
#udid ⇒ Object
Returns the value of attribute udid.
Instance Method Summary collapse
- #boot ⇒ Object
- #delete ⇒ Object
- #disable_slide_to_type ⇒ Object
-
#initialize(name: nil, udid: nil, os_type: nil, os_version: nil, state: nil, is_simulator: nil) ⇒ Device
constructor
A new instance of Device.
- #reset ⇒ Object
- #shutdown ⇒ Object
- #to_s ⇒ Object
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.
189 190 191 192 193 194 195 196 197 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 189 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_version ⇒ Object
Preserved for backwards compatibility
185 186 187 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 185 def ios_version @ios_version end |
#is_simulator ⇒ Object
Returns the value of attribute is_simulator.
187 188 189 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 187 def is_simulator @is_simulator end |
#name ⇒ Object
Returns the value of attribute name.
181 182 183 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 181 def name @name end |
#os_type ⇒ Object
Returns the value of attribute os_type.
183 184 185 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 183 def os_type @os_type end |
#os_version ⇒ Object
Returns the value of attribute os_version.
184 185 186 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 184 def os_version @os_version end |
#state ⇒ Object
Returns the value of attribute state.
186 187 188 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 186 def state @state end |
#udid ⇒ Object
Returns the value of attribute udid.
182 183 184 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 182 def udid @udid end |
Instance Method Details
#boot ⇒ Object
203 204 205 206 207 208 209 210 211 212 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 203 def boot return unless is_simulator return unless os_type == "iOS" return if self.state == 'Booted' # Boot the simulator and wait for it to finish booting UI.("Booting #{self}") `xcrun simctl bootstatus #{self.udid} -b &> /dev/null` self.state = 'Booted' end |
#delete ⇒ Object
230 231 232 233 234 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 230 def delete UI.("Deleting #{self}") shutdown `xcrun simctl delete #{self.udid}` end |
#disable_slide_to_type ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 236 def return unless is_simulator return unless os_type == "iOS" return unless Gem::Version.new(os_version) >= Gem::Version.new('13.0') UI.("Disabling 'Slide to Type' #{self}") plist_buddy = '/usr/libexec/PlistBuddy' plist_buddy_cmd = "-c \"Add :KeyboardContinuousPathEnabled bool false\"" plist_path = File.("~/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 |
#reset ⇒ Object
224 225 226 227 228 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 224 def reset UI.("Resetting #{self}") shutdown `xcrun simctl erase #{self.udid}` end |
#shutdown ⇒ Object
214 215 216 217 218 219 220 221 222 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 214 def shutdown return unless is_simulator return unless os_type == "iOS" return if self.state != 'Booted' UI.("Shutting down #{self.udid}") `xcrun simctl shutdown #{self.udid} 2>/dev/null` self.state = 'Shutdown' end |
#to_s ⇒ Object
199 200 201 |
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 199 def to_s self.name end |