跪拜 Guibai
← All articles
Frontend · Open Source · Testing

phone-harness Lets AI Agents Tap, Swipe, and Type on Real Phones Without Appium or Root

By 狂师 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The cost of mobile automation moves from environment setup and locator maintenance to a one-command install and an AI agent that reads the screen. That makes real-device tasks like verification codes, push regression, and on-device checks scriptable without app instrumentation, which is the bottleneck that has kept this kind of work manual.

Summary

phone-harness replaces the traditional mobile automation stack: no JDK, Android SDK, Appium Server, or Xcode-WebDriverAgent signing. It runs as a Python CLI and hands screen control to AI agents like Claude Code and Codex. On iPhone, it piggybacks on macOS's iPhone Mirroring and Apple's Vision OCR; on Android, it uses adb and the accessibility tree. Both paths expose the same script interface, so the same script runs on either platform.

The agent drives the phone by taking screenshots, reading the text on the screen, and injecting taps, swipes, and keystrokes. A script like `open_app("Notes")` then `tap_text("New Note")` reads like plain instructions. Around 50 pre-imported helper functions cover common actions, with built-in waits like `scroll_until` and `wait_for_text`, removing the need for manual sleep calls. A demo shows an agent hailing a real Waymo on an iPhone from a natural-language order.

Install is one command (`uv tool install --python 3.12 --upgrade --force phone-harness`), and the CLI includes `skill`, `doctor`, and `cloud` subcommands. Boundaries are stated plainly: the user must unlock the phone, OCR doesn't read icons, and multi-touch, camera, Face ID, and DRM video aren't covered. The underlying move is to treat the screen as the interface, sidestepping app instrumentation entirely, so any app can be automated without modification.

Takeaways
— phone-harness is a Python CLI, open-sourced under MIT, that lets AI agents control real phones via screen capture and touch injection.
— On iPhone it uses macOS iPhone Mirroring (macOS 15+, iOS 18+) and Apple Vision OCR; on Android it uses adb and the accessibility tree, on any OS with USB or Wi-Fi.
— The same script interface works on both platforms; about 50 pre-imported helper functions include open_app, tap_text, scroll_until, and wait_for_text.
— Install with `uv tool install --python 3.12 --upgrade --force phone-harness` or `pip install phone-harness`; requires uv and Python 3.12 (package supports 3.10+).
— Four CLI components: main command, `skill` to register agent skill, `doctor` for connection diagnostics, and `cloud` for per-minute cloud Androids.
— A demo in the README shows an agent hailing a real Waymo on an iPhone from the instruction 'Buy me a Waymo to Delah Coffee from my current location'.
— Limitations: user must unlock the phone, OCR only reads text not icons, and multi-touch, camera, Face ID, and DRM video are not supported.
Conclusions

Treating the screen as the interface removes the need for app instrumentation; any app can be automated without modification, which is a reversal of the traditional test-method approach.

The reliance on OCR and visual models shifts the maintenance burden from locator updates to model accuracy; UI changes now only break automation if the model can't read the new screen.

The limitations (no multi-touch, no camera, no Face ID) show that screen-level control is good for text-driven flows but not high-fidelity UI interactions, so the tool is a complement, not a replacement, for deep test frameworks.

Concepts & terms
iPhone Mirroring
A macOS feature (macOS 15+) that mirrors and controls an iPhone's screen on a Mac over Wi-Fi or cable; phone-harness captures this window for screen reads and input injection.
Accessibility tree
A structural representation of the UI elements on an Android screen, used by screen readers; phone-harness reads text from it to know what's on the screen.
Vision OCR
Apple's on-device text recognition framework; phone-harness uses it to extract text from iPhone mirror screenshots.
From the discussion
Featured comments
用户683530038274

Does phone-harness connect directly to the real device, or does it need an agent installed first?

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗