Most ways to automate an iPhone from a computer start with Xcode, Developer Mode, a signed helper app and a cable that has to stay plugged in. That's fine for a CI farm, but heavy if all you want is a small script: open Settings, take a screenshot, tap a button, check what happened.

This guide shows a lighter path. A ~$7 ESP32-S3 board plugs into the iPhone and acts as its mouse and keyboard, and it receives the phone's Screen Mirroring so your computer can see the screen. On the computer, one command-line tool, esp32agent, gives you screenshot, tap, swipe and type as ordinary shell commands. Every command prints JSON and exits non-zero on failure, so it fits into bash like any other tool.

The CLI is open source (MIT) in the esp32-iphone-agent repo and is part of Manina AI.

What you need

  • A plain Seeed Studio XIAO ESP32S3 (8 MB PSRAM, not the Sense or Plus variant), about $7.
  • A short USB-C data cable to plug the board into a USB-C iPhone. Lightning iPhones can use Bluetooth mode with the board on external USB power.
  • An iPhone with AssistiveTouch, which turns the board's mouse clicks and drags into taps and swipes.
  • A computer with Bluetooth: macOS, Linux or Windows. Screenshots also need ffmpeg.

You don't need the iPhone app for this. The CLI pairs with the board on its own.

1. Flash the board

Plug the board into your computer and flash it from Chrome or Edge at manina.ai/install. It runs in the browser, takes about half a minute, and there's nothing to install. The CLI can't find boards running firmware older than v0.2.2, so use the latest.

2. Install the CLI

Pick one:

# npm (Node.js 18+) npm install -g esp32agent # or the installer script from the official repo (macOS / Linux) curl -fsSL https://raw.githubusercontent.com/onehumanbeing/esp32-iphone-agent/main/cli/install/install.sh | sh 

The installers check each download's SHA-256, and esp32agent upgrade updates later. Only use install commands from the repo or manina.ai, never one-liners someone posts in an issue or comment.

If your shell says esp32agent: command not found after the script installer, make sure ~/.local/bin is on your PATH and open a new terminal.

3. Pair, mirror, and take your first screenshot

Plug the board into the iPhone (this powers it), then within three minutes:

esp32agent devices # boards nearby, with id / paired / connected esp32agent pair # pairs with the single nearby board 

You don't pair it in your computer's Bluetooth settings. The CLI does its own key exchange, so old OS Bluetooth bonds don't get in the way. If the three-minute window has passed, unplug the board, plug it back in and run pair again. With several boards around, use esp32agent pair --device <id> with the id from devices.

Then, on the iPhone:

  1. Settings → Wi-Fi: join the board's hotspot (ESP32Agent-…). With firmware v0.2.3 or later, esp32agent net shows its name and password.
  2. Control Center → Screen Mirroring → ESP32 Agent.
  3. Settings → Accessibility → Touch → AssistiveTouch: on, with the pointer visible.
  4. Keep the phone unlocked and in portrait.

Now:

esp32agent screenshot --output shot.png 

If shot.png shows your phone's screen, everything else in this guide will work.

4. The commands you'll script with

Command What it does
screenshot --output FILE the screen after the last action settled (PNG, or --format jpeg)
io tap X,Y tap; X,Y are pixels of a full-size screenshot. --count 2 double-taps
io longpress X,Y --duration MS long press
io swipe X1,Y1,X2,Y2 swipe or scroll
io text 'TEXT' type ASCII text
io keys COMBO enter, esc, tab, backspace, arrows, cmd+a …
io button HOME go to the Home Screen
device info board status: mirroring, video frozen, phone busy, USB/BLE link
calibrate measure the pointer (also runs on its own the first time you tap)

Output looks like {"status":"ok","data":...}, or {"status":"error","error":"..."} with exit code 1. That's all a script needs to decide whether to continue.

Getting coordinates. Take a screenshot, open it in any image viewer that shows pixel positions, and read off the point you want. Because coordinates are always in full-size screenshot pixels, the same numbers keep working as long as the screen layout doesn't change.

5. A first script: open Settings and capture each screen

The CLI can't launch apps directly, so the script does what a person would: go Home, pull down Spotlight, type the app name and press Enter.

#!/usr/bin/env bash # open-settings.sh — open Settings on a real iPhone and save a screenshot after each step set -euo pipefail OUT=./run-$(date +%Y%m%d-%H%M%S) mkdir -p "$OUT" step=0 # Run one esp32agent command; on error, stop with its message. ea() { local out if ! out=$(esp32agent "$@" 2>&1); then echo "esp32agent $* failed: $out" >&2 exit 1 fi } snap() { step=$((step + 1)) esp32agent screenshot --output "$OUT/$(printf '%02d' "$step")-$1.png" > /dev/null } ea io button HOME sleep 1 snap home # Swipe down from the middle of the Home Screen to open Spotlight. # Replace these with points from YOUR full-size screenshot. ea io swipe 240,400,240,700 sleep 1 snap spotlight ea io text 'Settings' ea io keys enter sleep 2 snap settings echo "Saved screenshots to $OUT" 

Run it with bash open-settings.sh and look at the folder: you get a picture of every step, which is the fastest way to see where a script went wrong.

The swipe coordinates above are placeholders. Take a Home Screen screenshot first, then pick a start point in the middle of the screen and an end point lower down.

6. Make it robust

A few things will bite you in real scripts. All of them come from how the board works, so they're worth knowing up front.

The phone can be busy. If the ESP32 Agent app on the iPhone is running a task, it has priority. Pointer and keyboard commands fail with busy: the app is using the phone while it drives the phone and for 20 seconds after. Retry instead of failing:

# retry an esp32agent command while the phone is busy (up to ~60 s) ea_retry() { local out i for i in $(seq 1 12); do if out=$(esp32agent "$@" 2>&1); then return 0; fi if grep -q 'busy' <<<"$out"; then sleep 5; continue; fi echo "esp32agent $* failed: $out" >&2 return 1 done echo "phone stayed busy: esp32agent $*" >&2 return 1 } 

Wait for the screen, not a fixed time. screenshot returns the screen after the last action settled, but apps take their own time to load. For anything slower than a Settings page, take a screenshot in a loop and compare it, or check it with whatever tool you already use for images, before the next tap.

Taps are mouse moves. The board is a mouse, not a touchscreen, so a tap is a relative pointer move. The CLI re-homes the pointer every 10 gestures, and accuracy depends on calibration. If taps start landing a little off, run esp32agent calibrate with the AssistiveTouch pointer visible, or add --aim to a tap that has to be precise:

esp32agent io tap 120,880 --aim 

Speed: move the link to Wi-Fi. Over Bluetooth, screenshots can lag up to about a second. If your computer and the board can share a 2.4 GHz home Wi-Fi, run:

esp32agent net join 

It asks for the Wi-Fi name and password (not echoed), sends them to the board over the paired Bluetooth session, and moves commands and video to Wi-Fi. Screenshots get close to live and taps no longer queue behind video. Bluetooth stays connected as the way back. Afterwards, join the same Wi-Fi on the iPhone and start Screen Mirroring to ESP32 Agent again. esp32agent net shows which link you're on, and esp32agent net hotspot switches the board back to its own hotspot.

Check health before a long run. esp32agent device info reports whether mirroring is up, whether the video is frozen, and whether the app holds the phone. Calling it at the start of a script saves you from a run that taps blindly at a stale screen.

7. Limits to plan around

  • Typing is ASCII only, one key per character. There's no clipboard. Chinese is typed as pinyin.
  • No app install or launch command, and no volume or power buttons. HOME is the only button. Open apps through Spotlight as above.
  • What AirPlay hides stays hidden. iOS doesn't mirror the passcode screen, Apple Pay, or DRM video, so a script can't see them. Keep the phone unlocked.
  • The mirrored stream is 480×1040 at up to 5 fps. That's plenty for UI checks, but this isn't a video-capture setup.
  • Portrait only on iPhone for now.

When a script isn't enough

Fixed coordinates work well for flows you control, like your own app's settings screen. They break when a layout shifts or a popup appears. That's when it helps to put a model in the loop: screenshot, decide, one action, screenshot again.

The same CLI covers that too. esp32agent mcp runs it as a local MCP server with the same tools (screenshot, tap, swipe, type_text and more), so a coding agent on your computer can drive the phone instead of a fixed script. The CLI docs have the setup for agents, remote agents and every command.

Troubleshooting quick list

  • devices finds nothing: flash the latest firmware (v0.2.2+ is required), keep the board close, and make sure your computer's Bluetooth is on.
  • pair fails: you're probably past the three-minute window. Unplug the board, plug it back in, retry.
  • Screenshot is black or old: the phone dropped off the board's Wi-Fi or Screen Mirroring stopped, often after a board restart. Rejoin the Wi-Fi and start mirroring again.
  • Taps do nothing: AssistiveTouch is off or the pointer is hidden.
  • Taps land a bit off: esp32agent calibrate, or io tap X,Y --aim.

Anything else: the troubleshooting page goes symptom by symptom.

Only automate phones and accounts that are yours or that you're allowed to operate, and keep a way to stop the script within reach.