Module: SimCtl::Command::IO

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

Instance Method Summary collapse

Instance Method Details

#screenshot(device, file, opts = {}) ⇒ void

This method returns an undefined value.

Saves a screenshot to a file

  • type: Can be png, tiff, bmp, gif, jpeg (default is png)

  • display: Can be main or tv for iOS, tv for tvOS and main for watchOS

Parameters:

  • device (SimCtl::Device)

    the device the screenshot should be taken from

  • file

    Path where the screenshot should be saved to

  • opts (defaults to: {})

    Optional hash that supports two keys:



14
15
16
17
18
19
20
# File 'lib/simctl/command/io.rb', line 14

def screenshot(device, file, opts = {})
  unless Xcode::Version.gte? '8.2'
    raise UnsupportedCommandError, 'Needs at least Xcode 8.2'
  end
  optional_args = opts.map { |k, v| "--#{k}=#{Shellwords.shellescape(v)}" }
  Executor.execute(command_for('io', device.udid, 'screenshot', *optional_args, Shellwords.shellescape(file)))
end