RemoteDebug iOS WebKit Adapter

repository·master·Indexed 25 days ago

https://github.com/remotedebug/remotedebug-ios-webkit-adapter

A protocol adapter (v0.4.2) that enables debugging of Safari and WebViews on iOS devices using Chrome Debugging Protocol compatible tools, such as Chrome DevTools, VS Code, and Mozilla debugger.html. It requires ios-webkit-debug-proxy and libimobiledevice to communicate with iOS devices.

Tokens
2.9K
Snippets
11
Records
28
Agent score
83%

What's inside remotedebug-ios-webkit-adapter

  1. Install system dependencies for iOS debugging

    master

    The adapter requires ios-webkit-debug-proxy and libimobiledevice to communicate with iOS devices. You must also have the latest version of iTunes installed.

    Linux

    Follow the installation instructions for ios-webkit-debug-proxy and libimobiledevice.

    Windows

    You can use scoop to install the required dependencies:

    scoop bucket add extras
    scoop install ios-webkit-debug-proxy

    OSX/Mac

    Use Homebrew to install the --HEAD versions of the required tools:

    brew update
    brew unlink libimobiledevice ios-webkit-debug-proxy usbmuxd
    brew uninstall --force libimobiledevice ios-webkit-debug-proxy usbmuxd
    brew install --HEAD usbmuxd
    brew install --HEAD libimobiledevice
    brew install --HEAD ios-webkit-debug-proxy
  2. Configure iOS Safari for remote debugging

    master

    To allow the adapter to detect your iOS targets, you must enable the Web Inspector on the device:

    1. Open iOS Settings.
    2. Navigate to Safari preferences.
    3. Enable Web Inspector.

    Additionally, ensure your computer trusts the iOS device. On macOS, you can use Safari to inspect an iOS Safari tab to establish trust. On Windows, iTunes may prompt you with a "Trust this computer" dialog.

  3. Configure the adapter using IAdapterOptions

    master

    When initializing or configuring the adapter, you can provide an IAdapterOptions object to control its behavior. Key options include:

    • pollingInterval: Frequency of polling (number).
    • baseUrl: The base URL for the adapter.
    • path: The specific path for the adapter.
    • port: The port number the adapter should run on.
    • proxyExePath: Path to a proxy executable.
    • proxyExeArgs: An array of arguments to pass to the proxy executable.
  4. Configure Adapter Options

    master

    When initializing an Adapter, you can provide an IAdapterOptions object. The following configuration keys are used to define how the adapter connects to the underlying debugging endpoint:

    • pollingInterval: The interval (in milliseconds) for polling targets. Defaults to 3000.
    • baseUrl: The base URL for the debugging endpoint. Defaults to http://127.0.0.1.
    • path: The path for the JSON endpoint. Defaults to /json.
    • port: The port for the debugging endpoint. Defaults to 9222.
    • proxyExePath: The path to the proxy executable required to start the adapter process.
    • proxyExeArgs: Arguments to pass to the proxy executable.
  5. Configure proxy settings for IOSAdapter

    master

    The IOSAdapter uses IIOSProxySettings to manage the connection via ios_webkit_debug_proxy. When calling getProxySettings(args), the adapter automatically constructs arguments for the proxy executable.

    If you are providing arguments via the args object, ensure proxyPort is specified. The adapter will generate a --config string in the format: --config=null:<proxyPort>,:<port_range> where the port range is a block of 100 ports starting from proxyPort + 1.

    Proxy Requirements:

    • Windows: The adapter looks for ios_webkit_debug_proxy.exe in Scoop directories (%SCOOP%/apps/ios-webkit-debug-proxy/current/ or %USERPROFILE%/scoop/apps/ios-webkit-debug-proxy/current/).
    • macOS/Linux: The ios_webkit_debug_proxy executable must be available in your system PATH.
  6. CLI Reference for remotedebug_ios_webkit_adapter

    master

    The following options are available for the remotedebug_ios_webkit_adapter command line tool:

    OptionDescription
    -p, --port [num]The adapter listening port (default: 9000)
    --versionPrints the current version
    Usage: remotedebug_ios_webkit_adapter --port [num]
    
    Options:
      -p, --port  the adapter listening port  [default: 9000]
      --version   prints current version
  7. Troubleshoot ios_webkit_debug_proxy installation

    master

    If the adapter fails to locate the proxy executable, check the following based on your operating system:

    • Windows: Ensure you have installed the proxy via Scoop. The adapter expects it at: path.resolve(__dirname, process.env.SCOOP + '/apps/ios-webkit-debug-proxy/current/ios_webkit_debug_proxy.exe').
      • Command to fix: scoop install ios-webkit-debug-proxy
    • macOS/Linux: Ensure ios_webkit_debug_proxy is in your system PATH.

    If you encounter device version detection errors, the adapter suggests updating ios-webkit-debug-proxy to version 1.8.5 or higher.