Sha256: 2df398b462fb5763dfc617410904a3f93c15b259876b77c7369b62616d3ff706

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

module SimCtl
  class Command
    module Launch
      XCODE_HOME = `xcode-select -p`.chomp
      SUPPORTED_SCALE = [1.0, 0.75, 0.5, 0.25]

      # Launches a Simulator instance with the given device
      #
      # @param device [SimCtl::Device] the device to launch
      # @return [void]
      def launch_device(device, scale=1.0)
        raise "unsupported scale '#{scale}' (supported: #{SUPPORTED_SCALE.join(', ')})" unless SUPPORTED_SCALE.include?(scale)
        # Launching the same device twice does not work.
        # Simulator.app would just hang. Solution: Kill first.
        kill_device(device)
        command = "open -n #{XCODE_HOME}/Applications/Simulator.app --args -ConnectHardwareKeyboard 0 -CurrentDeviceUDID #{device.udid} -SimulatorWindowLastScale-#{device.devicetype.identifier} #{scale}"
        system command
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simctl-1.2.3 lib/simctl/command/launch.rb
simctl-1.2.2 lib/simctl/command/launch.rb
simctl-1.2.1 lib/simctl/command/launch.rb
simctl-1.2.0 lib/simctl/command/launch.rb