Class: FastlaneCore::Simulator

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

Direct Known Subclasses

SimulatorTV, SimulatorWatch

Class Method Summary collapse

Class Method Details

.allObject



253
254
255
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 253

def all
  return DeviceManager.simulators('iOS')
end

.clear_cacheObject



291
292
293
294
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 291

def clear_cache
  @devices = nil
  @runtime_build_os_versions = nil
end

.copy_logs(device, log_identity, logs_destination_dir, log_collection_start_time) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 306

def copy_logs(device, log_identity, logs_destination_dir, log_collection_start_time)
  logs_destination_dir = File.expand_path(logs_destination_dir)
  os_version = FastlaneCore::CommandExecutor.execute(command: 'sw_vers -productVersion', print_all: false, print_command: false)

  host_computer_supports_logarchives = Gem::Version.new(os_version) >= Gem::Version.new('10.12.0')
  device_supports_logarchives = Gem::Version.new(device.os_version) >= Gem::Version.new('10.0')

  are_logarchives_supported = device_supports_logarchives && host_computer_supports_logarchives
  if are_logarchives_supported
    copy_logarchive(device, log_identity, logs_destination_dir, log_collection_start_time)
  else
    copy_logfile(device, log_identity, logs_destination_dir)
  end
end

.delete_allObject

Delete all simulators of this type



275
276
277
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 275

def delete_all
  all.each(&:delete)
end

.delete_all_by_version(os_version: nil) ⇒ Object



279
280
281
282
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 279

def delete_all_by_version(os_version: nil)
  return false unless os_version
  all.select { |device| device.os_version == os_version }.each(&:delete)
end

.disable_slide_to_type(udid: nil, name: nil, os_version: nil) ⇒ Object

Disable ‘Slide to Type’ by UDID or name and OS version Latter is useful when combined with -destination option of xcodebuild



286
287
288
289
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 286

def disable_slide_to_type(udid: nil, name: nil, os_version: nil)
  match = all.detect { |device| device.udid == udid || device.name == name && device.os_version == os_version }
  match.disable_slide_to_type if match
end

.launch(device) ⇒ Object



296
297
298
299
300
301
302
303
304
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 296

def launch(device)
  return unless device.is_simulator

  simulator_path = File.join(Helper.xcode_path, 'Applications', 'Simulator.app')

  UI.verbose("Launching #{simulator_path} for device: #{device.name} (#{device.udid})")

  Helper.backticks("open -a #{simulator_path} --args -CurrentDeviceUDID #{device.udid}", print: FastlaneCore::Globals.verbose?)
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



269
270
271
272
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 269

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_allObject

Reset all simulators of this type



258
259
260
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 258

def reset_all
  all.each(&:reset)
end

.reset_all_by_version(os_version: nil) ⇒ Object



262
263
264
265
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 262

def reset_all_by_version(os_version: nil)
  return false unless os_version
  all.select { |device| device.os_version == os_version }.each(&:reset)
end

.uninstall_app(app_identifier, device_type, device_udid) ⇒ Object



321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'fastlane_core/lib/fastlane_core/device_manager.rb', line 321

def uninstall_app(app_identifier, device_type, device_udid)
  UI.verbose("Uninstalling app '#{app_identifier}' from #{device_type}...")

  UI.message("Launch Simulator #{device_type}")
  if FastlaneCore::Helper.xcode_at_least?("13")
    Helper.backticks("open -a Simulator.app --args -CurrentDeviceUDID #{device_udid} &> /dev/null")
  else
    Helper.backticks("xcrun instruments -w #{device_udid} &> /dev/null")
  end

  UI.message("Uninstall application #{app_identifier}")
  Helper.backticks("xcrun simctl uninstall #{device_udid} #{app_identifier} &> /dev/null")
end