Class AppLauncher

java.lang.Object
org.robovm.libimobiledevice.util.AppLauncher

public class AppLauncher
extends java.lang.Object
Launches an application on a device using the com.apple.debuserver service. The app must have the get-task-allow entitlement set to true in order to be allowed to be launched by the debug server.
  • Field Details

  • Constructor Details

    • AppLauncher

      public AppLauncher​(IDevice device, java.lang.String appId)
      Creates a new AppLauncher which will launch an already installed app with the specified id.
      Parameters:
      device - the device to connect to.
      appId - the id (CFBundleIdentifier) of the app to run.
    • AppLauncher

      public AppLauncher​(IDevice device, java.io.File localAppPath) throws java.io.IOException
      Creates a new AppLauncher which will install the app from the specified IPA file or app bundle dir and launch it.
      Parameters:
      device - the device to connect to.
      localAppPath - the IPA file of app bundle dir containing the app to install and launch.
      Throws:
      java.io.IOException
  • Method Details

    • uploadProgressCallback

      public AppLauncher uploadProgressCallback​(AfcClient.UploadProgressCallback callback)
      Sets an AfcClient.UploadProgressCallback which will be used to report the progress when the app is uploaded to the device.
      Parameters:
      callback - the callback.
    • installStatusCallback

      public AppLauncher installStatusCallback​(InstallationProxyClient.StatusCallback callback)
      Sets an InstallationProxyClient.StatusCallback which will be used to report the progress when the app is installed on the device.
      Parameters:
      callback - the callback.
    • args

      public AppLauncher args​(java.lang.String... args)
      Adds command line arguments which will be passed to the app on launch.
      Parameters:
      args - the arguments to be added.
    • stdout

      public AppLauncher stdout​(java.io.OutputStream stdout)
      Sets an OutputStream which all console output (stdout and stderr) of the app will be written to when the app is launched. By default all output will be written to System.out
      Parameters:
      stdout - the OutputStream.
    • closeOutOnExit

      public AppLauncher closeOutOnExit​(boolean closeOutOnExit)
      Sets whether the stdout stream should be closed once the app has terminated.
      Parameters:
      closeOutOnExit - true or false.
    • env

      public AppLauncher env​(java.lang.String name, java.lang.String value)
      Adds an environment variable which will be set when launching the app.
      Parameters:
      name - the variable name.
      value - the variable value.
    • env

      public AppLauncher env​(java.util.Map<java.lang.String,​java.lang.String> env)
      Adds environment variables which will be set when launching the app.
      Parameters:
      env - the variables.
    • debug

      public AppLauncher debug​(boolean debug)
      Sets whether GDB protocol packets should be logged to System.out. Disabled by default.
      Parameters:
      debug - true to enabled debug logging.
    • forward

      public AppLauncher forward​(int localPort)
      Forwards all GDB communication to the local TCP port after the app has been successfully launched.
      Parameters:
      localPort - local port or -1 to disable
    • appLauncherCallback

      public AppLauncher appLauncherCallback​(AppLauncherCallback callback)
      Sets a callback that is invoked when the remote app info is known.
    • xcodePath

      public AppLauncher xcodePath​(java.lang.String xcodePath)
      Sets the path to Xcode where developer images will be searched for. This should be set to the value returned by xcode-select. If not set /Applications/Xcode.app/Contents/Developer will be used.
      Parameters:
      xcodePath - the Xcode path.
    • launchOnLockedRetries

      public AppLauncher launchOnLockedRetries​(int launchOnLockedRetries)
      Sets the number of times to retry a launch if the device is locked. Default is 5.
    • secondsBetweenLaunchOnLockedRetries

      public AppLauncher secondsBetweenLaunchOnLockedRetries​(int secondsBetweenLaunchOnLockedRetries)
      Sets the number of seconds to wait between launch retries when the device is locked. The default is 5.
    • kill

      public void kill()
    • log

      protected void log​(java.lang.String s, java.lang.Object... args)
      Logs a message to System.out. Override this method to use a custom logger.
    • install

      public void install() throws java.io.IOException
      Throws:
      java.io.IOException
    • launch

      public int launch() throws java.io.IOException
      Throws:
      java.io.IOException
    • main

      public static void main​(java.lang.String[] args) throws java.lang.Exception
      Throws:
      java.lang.Exception