Module: SimCtl::Command::Create

Included in:
SimCtl::Command
Defined in:
lib/simctl/command/create.rb

Instance Method Summary collapse

Instance Method Details

#create_device(name, devicetype, runtime) ⇒ SimCtl::Device

Creates a device

Parameters:

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/simctl/command/create.rb', line 12

def create_device(name, devicetype, runtime)
  runtime = runtime(name: runtime) unless runtime.is_a?(Runtime)
  devicetype = devicetype(name: devicetype) unless devicetype.is_a?(DeviceType)
  raise "Invalid runtime: #{runtime}" unless runtime.is_a?(Runtime)
  raise "Invalid devicetype: #{devicetype}" unless devicetype.is_a?(DeviceType)
  command = command_for('create', Shellwords.shellescape(name), devicetype.identifier, runtime.identifier)
  device = Executor.execute(command) do |identifier|
    device(udid: identifier)
  end
  device.wait { |d| d.state == :shutdown && File.exist?(d.path.device_plist) }
  device
end