2026-11-26 15:48 UTC

Experimental mobile-agent adds CLI and MCP control for Android and iOS

state: watchingheat: lowuncertainty: mediumrelevance: highmobile-agents device-control agent-toolsG. Esposito

What is this?

mobile-agent is G. Esposito’s experimental, pre-release open-source project for controlling Android devices and emulators, iOS Simulators, and some physical iPhones through a CLI or MCP server. The repository describes a daemon that maintains a live mirror of screen frames and accessibility trees so agents can inspect screens, act on elements, and check results. The project was featured on Hacker News on 31 October 2026; the supplied repository snapshot was fetched 30 October. It is built from source, depends on private Apple and hidden Android interfaces, and has only been tested on a narrow set of devices and OS versions. A separate Hacker News post on 4 November describes Umbra, an Android agent; its commenter’s ideas about background app control are not evidence that mobile-agent supports those capabilities.

Why it matters

A separate project’s reported on-device iPhone approach adds a meaningful alternative deployment model for AI-driven app use, while mobile-agent remains relevant as cross-platform development and testing infrastructure.

Current assessment

mobile-agent remains an experimental, pre-release open-source tool offering CLI and MCP control of Android devices and emulators, iOS Simulators, and some physical iPhones. Its daemon mirrors screen frames and accessibility state for an observe–act–verify loop; project-reported measurements are from limited setups, and broad reliability or adoption is not established. Physical iPhone support is narrow and requires substantial setup; the implementation relies on private Apple and hidden Android interfaces. A separate project, iphone-use-app, now claims an iPhone app can run an LLM agent that controls the phone itself with no Mac at runtime after one-time pairing; this is a distinct approach and does not confirm mobile-agent’s capabilities. The newer project’s claims and demonstrated workflow are repository-reported, not independent validation. The potential for native-app testing and workflows remains significant, but current engagement is low and there is no evidence of broad deployment.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p10momentum: steady1 platformsage 642h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

10-30 20:54⭐ origin directly observedShow HN: mobile-agent – Let AI agents control Android and iOS devices
tilt on hacker news
—
11-04 09:30first on hacker news · published · +108.6hShow HN: Umbra – An AI agent that uses Android apps while you use your phone
pinyen_cheng
—
10-30 20:54amplified on hacker news 👑hn.story.50310027
tilt
peak 2 · 0 comments · 29% of case engagement
11-04 09:30amplified on hacker newshn.story.50363170
pinyen_cheng
peak 1 · 1 comments · 29% of case engagement
11-05 18:36amplified on hacker newshn.story.50382696
erikkannike
peak 1 · 0 comments · 15% of case engagement
11-09 19:47amplified on hacker newshn.story.50430860
ea016
peak 2 · 0 comments · 29% of case engagement
10-30 21:22our radar first saw it · +0.5hdiscovery anchor: hn.story.50310027—
pace: p47 vs 1845 stories at the 336h mark (now 642h old) — ahead of agentplay-coding-agent-cost-dashboard (1.2x), behind agent-alley-social-experiment (0.9x)

Evidence (4) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hn ⭐Show HN: mobile-agent – Let AI agents control Android and iOS devices
Retrieved article excerpt

Open article · Retrieved 2026-10-30T21:24:15.139134+00:00

# mobile-agent

mobile-agent drives Android devices, Android emulators, iOS Simulators and physical iPhones for AI agents, and is designed around the latency of each tap-and-observe step. A daemon keeps a live mirror of every attached screen (its windows, accessibility tree and latest frame), updates it from the platform's change events and frame callbacks, and answers snapshots, waits and settle checks from that mirror instead of reading the device and sleeping on every request. On Android, a single-dex agent pushed over adb runs as the shell user under `app_process` and holds the device's UI automation role: no APK is installed and no instrumentation runs. On the iOS Simulator the driver works from the host: input goes through the Simulator's dtuhidd HID service, frames come from the display's IOSurface, and the accessibility tree comes from a Rust reader that the daemon spawns into the Simulator, with no XCTest runner and nothing installed. A physical iPhone's tree can be read only from an XCTest runner, so there a Rust runner built in this repository, started through the phone's test manager and kept for the session, serves the tree and text entry over the same device protocol, while the driver does the rest from the host: input through the developer disk image's dtuhidd, frames from screenshots it polls, and the phone's services over a CoreDevice tunnel it opens in its own process, without root or a helper. The `mobile-agent` CLI follows agent-browser's command grammar, `@eN` refs and JSON envelope, so prompts and skills written for agent-browser carry over where devices have the same concepts, and the `mobile-agent-mcp` server gives an MCP client the same tools, refs and replies (Agent surfaces).

**Status.** Experimental and pre-release: nothing is published to crates.io or as a binary yet, so mobile-agent is built from source (Build), and `main` is the version CI builds and tests on macOS and Linux. The drivers rely on private Apple and hidden Android interfaces, which makes this development tooling, never something to ship inside an app (Status and limitations). It is under the MIT License (`LICENSE`, `THIRD-PARTY-NOTICES.md`); `CONTRIBUTING.md` says how a change is made and checked, `SECURITY.md` how to report a vulnerability, and `CHANGELOG.md` what has changed.

## Supported platforms

| Platform | Status | Tested on |
| --- | --- | --- |
| macOS host | Simulator, Android and physical iPhone drivers, the iPhone's only when `MOBILE_AGENT_DRIVERS` names `ios` | macOS 26.6.2, Apple M1 Max |
| Linux host | Android driver only; the Simulator and iPhone drivers build as stubs | CI builds and tests it on `ubuntu-latest`, without a device |
| Xcode | for the Simulator driver, 26.0 up to, not including, 28; other versions are refused with `unsupported_xcode`. The iPhone's runner is built from Xcode's `XCTRunner.app` and iPhoneOS SDK, tried with 27.0 alone | Xcode 27.0 (27A266a); CI also builds with Xcode 26 |
| iOS Simulator | booted Simulators; no gate on the runtime version | iOS 26.5 (23F77), iPhone 17 |
| Android emulator | fast path through the emulator's gRPC controller when it answers, the agent's path with `--emulator-controller off` | API 36, arm64, Pixel 8 profile, Android Emulator 37.1.11 |
| Android agent | minimum API 26: the dex is built with `--min-api 26`, and a platform member that exists only from a later level is read behind a check of the level (`agent-android/src/dev/mobileagent/agent/Levels.kt`) | API 36 on the emulator; API 27 (Android 8.1) on a Nexus 5X, from agent 0.4.3 |
| Physical Android device | through the same agent, without a frame stream: taps and screenshots go through the agent | a Nexus 5X on Android 8.1 (API 27), a `user` build (`reports/10.3-physical-android.md`) |
| Physical iPhone | on USB, through a runner signed for a paid development team (Quick start); iOS 17.4 up to, not including, 27, other versions refused with `unsupported_ios`; input from the host from iOS 18, through the runner below it; built and measured for iOS 26, whose dtuhidd takes the host's input without a display stream, while iOS 27's, which needs one, is a later path (`crates/ios/README.md`, Compatibility) | an iPhone SE (3rd generation) on iOS 26.6.2 under Xcode 27.0, with `idevice` 0.1.68 (`reports/11.1-ios-device.md`) |

CI (`.github/workflows/ci.yml`) validates and runs no benchmark; the benchmarks have a workflow of their own, which never runs per push (How measurements are made). `ci.yml` runs `just validate` in three jobs: Linux, which also builds the Android agent and the Compose fixture; macOS with Xcode 26 on GitHub's `macos-26` image; and macOS with Xcode 27 on its `xcode-27` image. A fourth, Audit, lints the workflows with actionlint, audits them with zizmor, its online audits included, and checks the dependencies' advisories, licenses, bans and sources with cargo-deny (`deny.toml`). Every job starts without permissions and reads only what it needs, every action is pinned to a full commit SHA, no checkout keeps its credentials, and the tools come from lockfiles or from releases pinned with their SHA-256 (`docs/research/open-sourcing.md`). Each macOS job keeps the image's default Xcode when it has that major version and otherwise selects the newest `Xcode_<major>*.app`. The macOS jobs build and test the iPhone driver (`crates/ios`, on its fake device) and the runner's crate (`agent-ios`, on the host); nothing runs against a phone, the device tests skipping without `MOBILE_AGENT_IOS_UDID`, and the signed runner bundle is not built there, since `just agent-ios-build` skips with `SKIP_AGENT_BUILD=1` or without `MOBILE_AGENT_IOS_TEAM`, as `just agent-build` skips the Android agent with `SKIP_AGENT_BUILD=1`. The Simulator integration tests, the spikes and every measurement ran on Xcode 27.0 with CoreSimulator 1171.7 and iOS 26.5. Nothing has run on Xcode 26, where input would be touch only, through the older Indigo transport (`crates/simulator/README.md`, Compatibility).

## Build

Requirements:

- **Rust.** Install rustup. It takes the toolchain from `rust-toolchain.toml`: the version pinned there, with clippy, rustfmt and the `aarch64-apple-ios-sim` target. Run `rustup toolchain install` in the checkout, as CI does, to install them before the first build, or when cargo reports that the pinned toolchain is not installed; `rustup show active-toolchain` there names the toolchain in use.
- **macOS, for the Simulator.** Xcode 26 or 27, selected with `xcode-select`, with an iOS Simulator runtime; and libjpeg-turbo, `brew install jpeg-turbo`, which the frame encoder links statically from Homebrew's Apple silicon prefix (`.cargo/config.toml`; set `TURBOJPEG_LIB_DIR` and `TURBOJPEG_INCLUDE_DIR` for another prefix).
- **The Android agent.** The daemon's build compiles the agent with `agent-android/build.sh` (kotlinc and R8, no Gradle) and embeds the jar, so it needs a JDK 17 or newer with `java` and `jar` on `PATH` (tested with Temurin 21), the Kotlin compiler, `kotlinc` on `PATH` or `KOTLIN_HOME` set to the compiler's home, the directory holding `bin/kotlinc` and `lib/` (tested with 2.4.20), and an Android SDK at `ANDROID_HOME`, by default `$HOME/Library/Android/sdk`, with `platforms;android-36` and a `build-tools` package (CI installs 37.0.0). On Linux, set `ANDROID_HOME`.
- **Android at run time.** The SDK's `platform-tools`, whose adb server the driver talks to on port 5037, and for an emulator, the `emulator` package and an AVD.
- **The iPhone's runner.** `agent-ios/build.sh`, which `just agent-ios-build` runs, builds the runner for `aarch64-apple-ios`, the second target `rust-toolchain.toml` names, links it into a copy of Xcode's `XCTRunner.app` with the iPhoneOS SDK's `clang` and signs it with `codesign` for the team `MOBILE_AGENT_IOS_TEAM` names, with no `xcodebuild` project, into the git-ignored `agent-ios/dist/` (`agent-ios/README.md`, Building and signing). It needs Xcode 27.0's iPhoneOS SDK, the only one tried, and the team's identity and profile (Quick start). The daemon installs that bundle from the workspace it was built in, or the one `MOBILE_AGENT_IOS_RUNNER_APP` names, when the phone's runner is missing or says hello with another version (`crates/daemon/README.md`, The physical iPhone driver).

From the checkout:

```
cargo build --release                      # target/release/mobile-agent, mobile-agent-daemon and mobile-agent-mcp
export PATH="$PWD/target/release:$PATH"    # the CLI starts the daemon it finds beside itself
```

- `cargo build --profile profiling` builds the release code with line-level debug information and nothing stripped, into `target/profiling/`, for a sampling profiler such as Instruments' Time Profiler, which then names inlined functions and lines; release builds strip the debug information (spike S15, `docs/spikes/s15-profiles.md`).
- `SKIP_AGENT_BUILD=1 cargo build --release` builds without the Android toolchain. That daemon deploys an agent only from a jar that `MOBILE_AGENT_JAR` names at run time; `MOBILE_AGENT_JAR` set at build time embeds that jar instead of building one.
- The Simulator's tree reader is cross-compiled for `aarch64-apple-ios-sim` during the build and embedded in the daemon, behind the `reader` feature of `crates/simulator`, which is on by default. The daemon spawns it into each booted Simulator it attaches. Without that Rust target the build warns and embeds no reader, and tree reads fall back to the slower host translator, marked degraded; `doctor` shows which one a build has.
- Contributors: every dependency install goes through Socket Firewall. Install it with `npm i -g sfw`, then prefix installs with it: `sfw cargo fetch`, `sfw cargo add`, `sfw cargo install just`, `sfw npm install -g @fission-ai/openspec`. `just validate` runs the checks a change must pass: build, clippy with warnings denied, format check, the publish scan (`just check-public`: no machine path, device identifier, team id, email, host model or private term in a tracked file, and gitleaks' rules when it is installed), the workflows' lint and audit (actionlint and zizmor, when installed), the dependencies' check (`cargo deny`, when installed), tests, the checks of the repository's own scripts, the agent build, the iPhone runner's build, the Kotlin codec cross-check, the fixture scripts' checks with fake build tools, the fixture builds (with the SwiftUI and Expo fixtures' device builds when `MOBILE_AGENT_IOS_TEAM` is set) and `openspec validate`. The tests that need a Simulator, an emulator or an iPhone skip unless their environment names one (`crates/daemon/README.md`, `crates/simulator/README.md`, `crates/ios/README.md`).

## Quick start

The daemon attaches to targets that are already running; it boots nothing. For Android, put the SDK's tools on `PATH`, start an adb server, and start an emulator with its gRPC control endpoint, whose port is the console port plus 3000, or connect a device with USB debugging on and its prompt accepted:

```
export ANDROID_HOME="${ANDROID_HOME:-$HOME/Library/Android/sdk}"
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
adb start-server
emulator -avd <name> -grpc 8554 -grpc-use-token      # in a terminal of its own
```

Without the control endpoint, taps and screenshots go through the agent and there is no frame stream; `doctor` and `status` say how to enable it on a running emulator: `adb -s emulator-5554 emu grpc 8554`. Emulator 37.1.11 serves the endpoint even when started without `-grpc` (only `-ports` leaves it off), so to take the agent's path on an emulator that serves it, as a physical device does, start the daemon with `--emulator-controller off` or `MOBILE_AGENT_EMULATOR_CONTROLLER=off`; `status` and `doctor` report the setting. For the iOS Simulator, boot one in Simulator.app or with `xcrun simctl boot <name or UDID>`.

For a physical iPhone, the daemon registers its driver only when `MOBILE_AGENT_DRIVERS` names `ios` (`MOBILE_AGENT_DRIVERS=ios` drives iPhones 
tilt20
🟧 hnShow HN: Umbra – An AI agent that uses Android apps while you use your phonepinyen_cheng11
🟧 hnShow HN: Is Android ready for AI agents? What broke in 3324 actions on 45 phoneserikkannike10
🟧 hnShow HN: Open-source app that lets LLMs control your iPhone (no Mac required)
Retrieved article excerpt

Open article · Retrieved 2026-11-09T20:22:48.392162+00:00

[iphone-use-app icon](https://github.com/EliotAndres/iphone-use-app/blob/main/docs/images/logo.png)

# iphone-use-app

**Let an AI model use your iPhone, from the iPhone itself. No Mac at run time (one-time pairing only), no extra hardware, no jailbreak.**

[iOS](https://camo.githubusercontent.com/d78bc159f387bb2311f60bc4681bbf0ce28965c7b67341f865e1ba237b302ce1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f694f532d32362532422d626c61636b)
[License: AGPL-3.0](https://github.com/EliotAndres/iphone-use-app/blob/main/LICENSE)
[Swift + Rust](https://camo.githubusercontent.com/8b1e4f9fcd43ccccb608df4a04ad5adcfc47a3d9f3a93d5c661ecff3faf9d903/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5377696674253230253242253230527573742d6f72616e6765)

[Demo: the agent picks a Lyft ride to the Eiffel Tower](https://github.com/EliotAndres/iphone-use-app/blob/main/docs/demo.mp4)
[The finished run: each step with its screenshot, then the agent's summary](https://github.com/EliotAndres/iphone-use-app/blob/main/docs/images/screen-steps.jpg)
[A new chat with suggested prompts](https://github.com/EliotAndres/iphone-use-app/blob/main/docs/images/screen-home.jpg)

*Left: "Select a Lyft to the Eiffel Tower (don't book yet)" (4× speed): the agent leaves its own app, opens Lyft,
types the destination, picks it and stops at the ride options. Middle: the finished run, each step with its screenshot. Right: a new chat.*

## Features

- **No computer at run time:** the agent runs on the iPhone and controls that same iPhone, no extra hardware or jailbreak.
  A Mac is only needed once, to make the pairing file
- **Start it from anywhere:** the chat, Siri, the "Run Agent" Shortcut or an `iphoneuse://run?prompt=…` link.

## How it compares

|  | iphone-use-app | [TapKit](https://tapkit.ai) | [esp32-iphone-agent](https://github.com/onehumanbeing/esp32-iphone-agent) | [iPhone-use](https://github.com/zhongerxin/iPhone-use) |
| --- | --- | --- | --- | --- |
| **Computer at run time** | None (a Mac once, for pairing) | Mac app, phone plugged in | None (a computer once, to flash the board) | Mac (MCP server) |
| **Extra hardware** | None | None | ESP32-S3 board (~$7) on USB-C | None |
| **How it sees and acts** | CoreDevice screenshots and touches, through a loopback VPN | Apple accessibility features | AirPlay mirroring to the board, USB mouse/keyboard via AssistiveTouch | WebDriverAgent (XCTest) over USB |

## Requirements

| Part | Notes |
| --- | --- |
| **iPhone** | iOS 26 or later, Developer Mode on. |
| **Apple account** | **Paid team:** the app uses its own built-in VPN (needs the Network Extension entitlement). **Free Apple ID:** build with `BUILTIN_VPN=NO` (Xcode build setting or `xcodebuild` argument) and install [LocalDevVPN](https://apps.apple.com/app/localdevvpn/id6755608044); re-sign every 7 days. |
| **Pairing file** | Made once from a Mac over USB (below). |
| **Vision model** | An [OpenRouter](https://openrouter.ai/settings/keys) key, or any OpenAI-compatible endpoint whose model takes images and tool calls. |
| **Mac** | Only to make the pairing file (and to build the app, unless you install the release). Not needed at run time. |

## Limitations

- **Shortcut needed on cellular:** iOS refuses new loopback VPN connections on cellular data, so the app runs a
  Cellular Toggle shortcut that turns data off while it connects, then back on (or turn it off by hand).
- **No other VPN at the same time:** it needs a loopback VPN (the built-in one, or
  [LocalDevVPN](https://apps.apple.com/app/localdevvpn/id6755608044)), and iOS allows one VPN at a time, so
  Tailscale and similar stop while it is on.
- **"Viewed remotely from Mac" notice on every run:** iOS shows "Device Hub: This device was viewed remotely from
  Mac" when its developer services are used, even though the "Mac" here is the app itself. Nothing leaves the phone (except calls to LLMs).
- **Permissions:** requires Developer Mode, a VPN configuration, Local Network access (to find the phone's
  pairing service), and Location set to "Always" (keeps runs alive in the background, alongside silent audio).
  Microphone only for voice prompts.
- **Pairing files expire:** make a new one when the app says so.
- **Sideloaded build only:** it needs Developer Mode and developer services, so it can't go on the App Store.
- **A few seconds per step:** most of it is the model.

## How it works

```
flowchart LR
  subgraph App["iphone-use-app"]
    L["LLM calling"]
    D["Mount developer image"]
    O["Orchestrator"]
  end
  L <-- "screenshot + history /<br/>tool call" --> R["OpenRouter"]
  D -- "DDI mount" --> V["Loopback VPN<br/>10.7.0.1"]
  O <-- "screenshot / tap, swipe, type" --> V
```

 Loading

The app mounts a developer image, then uses a loopback VPN to screenshot and control the iPhone it runs on.
Each step, the screenshot goes to the model, which answers with a tool call (tap, long press, swipe, type, open app) until it's done.
A Live Activity shows progress with a Stop button, and every run is saved as a chat.

## Benchmark

One decision is one screenshot → one tool call. `scripts/eval.sh` replays 11 recorded steps (open Lyft, search a
destination, pick a ride, stop before paying; write a note) against each model through OpenRouter, run twice
(22 decisions per row). November 2026; times are full round trips from a Mac.

| Model | Correct | Median | p90 | $ / decision |
| --- | --- | --- | --- | --- |
| **Claude Haiku 5.5 (default)** | 91% | 1.3 s | 2.0 s | $0.0003 |
| Claude Haiku 5.5, reasoning off | 91% | 1.1 s | 1.5 s | $0.0003 |
| Claude Sonnet 5.5 (reasoning can't be turned off) | 91% | 1.2 s | 2.5 s | $0.0055 |
| Claude Opus 5 | 95% | 2.1 s | 4.2 s | $0.014 |
| Claude Opus 5, fast tier, reasoning off | 100% | 1.4 s | 1.6 s | $0.051 |
| Claude Opus 5.5 | 86% | 1.8 s | 3.1 s | $0.011 |
| Claude Opus 5.5, fast tier | 82% | 0.9 s | 1.3 s | $0.021 |

## Quick start

### 1. Make a pairing file

This is the one step that needs a Mac. Plug the phone into the Mac, unlock it (tap Trust if asked), then:

```
git clone https://github.com/jkcoxson/idevice && cd idevice
cargo build --release -p idevice-tools --bin idevice-tools
./target/release/idevice-tools rppairing pair my-mac pairingFile.plist
```

The file keeps working until the phone stops trusting that host (Reset Location & Privacy, Developer Mode turned off).
Make a new one if the app says the pairing file is invalid or expired.

### 2. Install the app

**Without building:** add this source in [SideStore](https://sidestore.io) or [AltStore](https://altstore.io):
`https://raw.githubusercontent.com/EliotAndres/iphone-use-app/main/source.json`
(or sideload the `.ipa` from [Releases](https://github.com/EliotAndres/iphone-use-app/releases/latest)).
It is the free Apple ID build: install [LocalDevVPN](https://apps.apple.com/app/localdevvpn/id6755608044) too.

**From source** (needed for the built-in VPN, which takes a paid team):

```
# once: the prebuilt Rust lib (45 MB, gitignored) from the latest release...
curl -L -o iPhoneUse/idevice/libidevice_ffi.a https://github.com/EliotAndres/iphone-use-app/releases/latest/download/libidevice_ffi.a
# ...or build it yourself (needs rustup + the aarch64-apple-ios target)
scripts/build-idevice.sh
open iPhoneUse.xcodeproj        # set your team, run the iPhoneUse scheme on the phone
```

### 3. Set up (once, in the app)

1. Settings (gear, top right) → **Import Pairing File**.1
2. Allow the **Add VPN Configuration** prompt. It only routes `10.7.0.1` back to the phone.
   With LocalDevVPN instead: turn it on, and pick LocalDevVPN in Settings → Phone Connection
   (picked for you if the built-in VPN fails).
3. Settings → **Model**: pick a provider, paste the key, pick a model.
4. Wait for the "not connected" line above the input to go away (the developer disk image downloads on first run).

1 Or copy it over once the app is installed:
`xcrun devicectl device copy to --device <udid> --domain-type appDataContainer --domain-identifier blog.eliot.iphoneuse --source pairingFile.plist --destination Documents/pairingFile.plist`

### 4. Give it a task

Type a goal, for example *"Open Settings and turn on Dark Mode"*, and send it. Stop it from the Dynamic Island
or the chat.

## Development

#### Scripted runs (no LLM)

```
DEV=<udid> scripts/runscript.sh "open com.apple.Preferences; wait 1.5; tap 0.5 0.9; shot a" a
```

Launches the app with `-agentScript`, waits for "script done" in `Documents/agent.log` and pulls the screenshots.
`-agentPrompt "..."` as a launch argument starts a real run.

#### Simulator (layout checks only)

The simulator can't reach a device, but it shows the UI. `-demoChat YES` plays a fake run
(placeholder screenshots, a question to answer), Debug builds only.

1. `rustup target add aarch64-apple-ios-sim && scripts/build-idevice.sh sim`: the libs are
   single-arch, so the simulator needs its own, in `iPhoneUse/idevice/sim/`.
2. Build Debug (the scheme defaults to Release, which drops `-demoChat`) against that lib:
   `xcodebuild -project iPhoneUse.xcodeproj -scheme iPhoneUse -configuration Debug -destination id=<sim udid> LIBRARY_SEARCH_PATHS='$(PROJECT_DIR)/iPhoneUse/idevice/sim' build`
3. Install the `.app` from DerivedData and launch it with `-demoChat YES`.

#### Heartbeat connection closes right after connecting (fixed: runs used to get killed)

**Symptom (before the fix):** a run froze on a step after about a minute in the background, and the
Live Activity stayed on that step. The app had been killed: the phone's crash logs held an
`iPhoneUse.cpu_resource_fatal-*.ips` report ("exceeding limit of 80% cpu over 60 seconds", "Process killed").

**Cause:** the heartbeat thread (`Heartbeat.run()` in `DeviceSession.swift`) keeps CoreDevice services
alive during a run. Its connection is closed right after the handshake; idevice's userspace TCP stack
(jktcp) then answers every read with `BrokenPipe` in microseconds, and the loop retried with no delay,
about 45k times a second. iOS kills background apps above 80% CPU over 60 seconds.

Two things made it worse:

- The idevice log was written to `Documents/idevice_log.txt` at Debug level, which prints every XPC
  message, screenshots included, as decimal byte lists: 178 MB of log and ~1 GB of memory in a minute.
- The loop matched errors by the strings `HeartbeatTimeout` / `HeartbeatSleepyTime`, which never
  appear in idevice's messages ("heartbeat timeout", "device went to sleep").

**Fix:** timeouts are matched on the error code (100, sub-code 2) and the loop waits again; any other
error ends the loop. The file log is at Info.

**Still open:** why the heartbeat connection closes. Runs work without it (a 17-step, 2.5-minute run
finished fine); if CoreDevice services start dropping on long runs, reconnecting the heartbeat
(with backoff) is the next step.

**Debugging a killed run:** `idevicecrashreport -u <udid> -k <dir>` pulls the crash logs. Symbolicate
with `atos` against the dSYM of the exact build (the UUID in the report must match
`dwarfdump --uuid`).

Feature scope: [docs/FEATURES.md](https://github.com/EliotAndres/iphone-use-app/blob/main/docs/FEATURES.md).

## Responsible use

Only automate devices and accounts you own or may use, and respect the terms of the apps involved. The agent acts
with your hands: watch it, and keep Stop within reach.

## Credits

| Project | Repo | Used for |
| --- | --- | --- |
| StikDebug, by Stephen and contributors | [StikDebug/StikDebug](https://github.com/StikDebug/StikDebug) | The tunnel, pairing file and developer disk image code is based on it |
| idevice, by jkcoxson | [jkcoxson/idevice](https://github.com/jkcoxson/idevice) | The Rust library behind every device call |
| StosVPN, by the SideStore Team and Stossy11 | [SideStore/StosVPN](https://github.com/SideStore/StosVPN) | The loopback VPN (`TunnelProvider/`) is based on it |
| LocalDevVPN, by jkcoxson | [jkcoxson/LocalDevVPN](https://github.com/jkcoxson/LocalDevVPN) | The VPN app for
ea01620

Interpretation history

Decision trace