> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobilerun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# iOS Driver

`IOSPortalHttpDriver` connects to the local server started by `mobilerun-ios --local`. Import it from `mobilerun_core_local`.

***

<span id="mobilerun_core_local.driver.ios.IOSPortalHttpDriver" aria-hidden="true" />

## IOSPortalHttpDriver

```python theme={null}
class IOSPortalHttpDriver(PortalHttpDriver)
```

Start the local server before creating the driver:

```bash theme={null}
mobilerun-ios --local <udid>
```

The server uses WebDriverAgent. Taps and gestures use logical iOS points. Screenshots may use a different pixel size; `input_coordinate_size()` returns the correct input dimensions.

### Constructor

```python theme={null}
def __init__(
    url: str,
    token: str | None = None,
    *,
    timeout: float = 30.0,
) -> None
```

* `url` is the server base URL, normally `http://127.0.0.1:8080`.
* `token` is optional for a loopback server. It must match `--local-token` when the server requires authentication.
* A `401` or `403` during connection raises `PermissionError` with token guidance.

### Supported methods

```python theme={null}
IOSPortalHttpDriver.supported = {
    "tap",
    "swipe",
    "input_text",
    "press_button",
    "press_key_code",
    "start_app",
    "stop_app",
    "install_app",
    "get_apps",
    "list_packages",
    "screenshot",
    "get_ui_tree",
    "get_date",
}

IOSPortalHttpDriver.supported_buttons = {
    "home", "back", "enter", "delete", "app_switch"
}
```

`uninstall_app()` raises `PlatformUnsupportedError`. `drag()` raises `NotImplementedError`; use `swipe()` instead.

### Methods

| Method | Behavior |
| - | - |
| `connect()` | Verifies the Portal HTTP server through `GET /version`. |
| `tap(x, y)` | Taps at logical iOS point coordinates. |
| `swipe(x1, y1, x2, y2, duration_ms)` | Performs a coordinate-based swipe; duration is milliseconds. |
| `input_text(text, clear=False, ...)` | Types into the focused field and can clear it first. |
| `press_button(name)` | Presses `home`, `back`, `enter`, `delete`, or `app_switch`. |
| `press_key_code(code)` | Sends a supported integer key code to the local server. |
| `start_app(bundle_id)` | Launches by bundle identifier. |
| `stop_app(bundle_id)` | Stops an app by bundle identifier. |
| `install_app(path_or_url)` | Installs an app from a path on the Mac or a URL. |
| `get_apps()` / `list_packages()` | Lists installed apps, with optional system-app filtering. |
| `screenshot()` | Returns raw PNG bytes from `/screenshot`. |
| `get_ui_tree()` | Returns the accessibility tree and device state. |
| `get_date()` | Returns the device date and time as an ISO-formatted timestamp. |

### Direct usage

```python theme={null}
import asyncio
from mobilerun_core_local import IOSPortalHttpDriver

async def main() -> None:
    driver = IOSPortalHttpDriver("http://127.0.0.1:8080")
    await driver.connect()

    await driver.start_app("com.apple.Preferences")
    await driver.tap(200, 400)
    await driver.input_text("hello", clear=True)
    await driver.press_button("home")

asyncio.run(main())
```

***

## See Also

* [AndroidDriver](/framework/sdk/adb-tools)
* [DeviceDriver Base Class](/framework/sdk/base-tools)
* [Device Setup — iOS](/framework/guides/device-setup)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.