Sha256: 84362ac454d0002c2ff7c3a4130a22e9fa64ae4ba54d4a4fb30011bb461677b7
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
require 'shellwords' module SimCtl class Command module Launch LAUNCH_APP_COMMAND = 'xcrun simctl launch' SUPPORTED_SCALE = [1.0, 0.75, 0.5, 0.25] XCODE_HOME = `xcode-select -p`.chomp # 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, opts={}) 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) args = { '-ConnectHardwareKeyboard' => 1, '-CurrentDeviceUDID' => device.udid, "-SimulatorWindowLastScale-#{device.devicetype.identifier}" => scale, } args.merge!({ '-DeviceSetPath' => Shellwords.shellescape(SimCtl.device_set_path) }) unless SimCtl.device_set_path.nil? args = args.merge(opts).zip.flatten.join(' ') command = "open -Fgn #{XCODE_HOME}/Applications/Simulator.app --args #{args}" system command end # Launches an app in the given device # # @param device [SimCtl::Device] the device to launch # @param opts [Hash] options hash - `{ wait_for_debugger: true/false }` # @param identifier [String] the app identifier # @param args [Array] optional launch arguments # @return [void] def launch_app(device, identifier, args=[], opts={}) launch_args = args.map {|arg| Shellwords.shellescape arg} launch_opts = opts[:wait_for_debugger] ? '-w' : '' Executor.execute(command_for('launch', launch_opts, device.udid, identifier, launch_args)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
simctl-1.5.8 | lib/simctl/command/launch.rb |
simctl-1.5.7 | lib/simctl/command/launch.rb |
simctl-1.5.6 | lib/simctl/command/launch.rb |