Sha256: 539dc5fc36a2adc1374c931cfed20e2f230b8a2e10f879994acb486b0f48b7b9

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

require 'shellwords'

module SimCtl
  class Command
    module Create
      COMMAND = %w[xcrun simctl create]

      # Creates a device
      #
      # @param name [String] name of the new device
      # @param devicetype [SimCtl::DeviceType] device type of the new device
      # @param runtime [SimCtl::Runtime] runtime of the new device
      # @return [SimCtl::Device] the device that was created
      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)
        Executor.execute([COMMAND, Shellwords.shellescape(name), devicetype.identifier, runtime.identifier]) do |identifier|
          device(udid: identifier)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simctl-1.5.0 lib/simctl/command/create.rb
simctl-1.4.1 lib/simctl/command/create.rb
simctl-1.4.0 lib/simctl/command/create.rb
simctl-1.3.1 lib/simctl/command/create.rb
simctl-1.3.0 lib/simctl/command/create.rb