# ipb `ipb` (iOS Physical-device Bridge, "the adb for iPhone"; formerly devicehubctl and briefly hdb) is a small CLI for driving basic iOS 27 device interactions through CoreDevice private services, without XCUITest or WebDriverAgent. It was extracted from a macOS 27 / Xcode 27 beta Device Hub investigation. It drives the device itself over the CoreDevice HID path — tap, long press, swipe, drag-scroll, trackpad scroll, keyboard keys, Home, App Switcher, side button (lock/wake), pointer and raw HID reports, plus a live JPEG screen stream (`ipb stream`) and an interactive mirror window (`ipb mirror`) — and wraps `xcrun devicectl` for everything Apple already exposes: install, launch, files, clipboard, location, screenshots. In this source revision, `ipb ui --deep` reads an application's native deep accessibility tree, numerical element frames over the DevicesApp raw DTX service. `ui hit-test` reads the actual element at a point; `ui press` resolves and presses a fresh element once. v0.5.0 adds exact locators/waits, selector-qualified press, text replacement that checks the actual first responder, one-shot scroll-to-visible and explicitly selected system-alert buttons. Since v0.4.0, `--deep` is a native-only observation (JSON schema 2); `--deep --full-state` adds separately reported state/role reads under `supplementalAX`. A failed supplementary read returns nonzero while preserving a validated native tree after successful cleanup. Default `ipb ui` retains the ordinary AXChildren graph and JSON schema 1. It uses an optional host Python backend; it installs nothing on the phone and starts no XCTest session. This is an AX graph, not a dump of every UIKit view. v0.6.0 adds `ipb mcp` for agent tools, a static `support --json` inventory and opt-in Python AX error receipts. Default CLI errors/exit codes and successful ordinary/deep schemas remain compatible. MCP invokes the existing CLI; no phone Runner, XCTest, new device protocol or AX dependency upgrade is introduced. The CLI uses DeviceHub's captured async descriptor-discovery path to resolve the touchscreen service when `UHID_SERVICE_ID=auto`. On 2026-11-03 the maintainer authorized v0.6.0 publication after Opus 5.5 review and host/package/Homebrew checks, deferring physical-device testing for this version. Earlier scoped12mini controls remain separate evidence. The full supported device gate and device-facing MCP effects remain unverified. See [current verification scope](docs/verification.md#open-items--current-state-living-section). For `ui press`, exit **6** means failure after submission: the diagnostic preserves accepted, refused or unknown status. Never retry it automatically; read the page again first. [Install and update](#installation-channels) · [Commands](#usage) · [UI tree](docs/ui.md) · [Mirror](docs/mirror.md) · [Documentation map](docs/README.md) ## Requirements - A host whose installed CoreDevice package is 636.x or newer. This ships with Xcode 27 beta (`XcodeSystemResources.pkg`); it is what puts `UniversalHIDService`, the `HIDServiceID` helpers, and the embedded `UniversalHID.framework` into `/Library/Developer/PrivateFrameworks`. - macOS 27 + Xcode 27 beta on the host (the supported target matrix). macOS 26.5.1 has separate development verification records; those do not expand the supported release matrix. The link step needs the beta SDK's private-framework stubs, and the beta's iOS DDI is what installs the device-side HID daemon (`dtuhidd`). - A connected iOS 27+ device visible to `xcrun devicectl`, with the Xcode 27 beta DDI mounted. iOS 26 is no longer a supported target (dropped 2026-09-20, no device available to verify against). On iOS 26 the `touchscreenGesture` service (`0x501`) was absent, so `pointer`, `abs-pointer`, `scroll-report`, `scroll-gesture` and the mirror's scroll wheel never worked there. See `docs/verification.md`. - GitHub-hosted code should be treated as beta/private-ABI research, because Apple may change these interfaces between seeds. Xcode 26.x hosts cannot run this tool as-is: CoreDevice 518.x lacks the UniversalHID service protocol, and the Xcode 26 DDI ships no HID daemon, so every `feature.remote.hid.*` / `universalhidservice` socket request is refused with "Create Service Socket is not supported by this device". The Xcode used for building and for `screenshot` is taken from `xcode-select -p`, which honours `DEVELOPER_DIR`: ```sh export DEVELOPER_DIR=/path/to/Xcode-beta.app/Contents/Developer ``` Override it at build time with `XCODE_PATH=/path/to/Xcode-beta.app` if you prefer. ## Installation channels The v0.6.0 source revision includes the MCP agent bridge in [PR #12](https://github.com/ipbtools/ipb/pull/12) and machine-readable error/support contracts in [PR #11](https://github.com/ipbtools/ipb/pull/11). It retains native deep schema2, ordinary/action schema1 and the existing runner-free element operations. Stable installs use the precompiled macOS 27 ARM64 package; source/HEAD installs build locally. The maintainer authorized publication after review and host/package/Homebrew checks without a new phone run; this does not certify the full physical-device matrix. See [release verification](docs/releasing.md#current-channels). Published archives are listed on the [latest stable Release](https://github.com/ipbtools/ipb/releases/latest); version preparation and CI packages do not publish or update the stable tap automatically. | Channel | What it installs | Update path | | --- | --- | --- | | Stable Homebrew | Pinned archive from the latest published stable release | `ipb update` or `brew upgrade ipbtools/ipb/ipb` | | Homebrew HEAD | Source from `main`, including the merged UI and mirror additions | `brew install --HEAD ipbtools/ipb/ipb`; `ipb update` keeps it current | | Release archive | Selected version with checksum/build metadata | Download a newer Release; keep bin/libexec/share together | | PR CI test package | Temporary precompiled development package | Download a newer Actions artifact | | Development source | The selected source checkout | Run `bin/ipb update` in that checkout | | `make install PREFIX=...` | A local copy of the selected checkout | Pull/build, then repeat install with the same prefix | ### Homebrew stable release Install the pinned stable package: ```sh brew update brew install ipbtools/ipb/ipb ``` To move an existing Homebrew `--HEAD` install to stable, first remove the HEAD install and then install the stable formula. `brew reinstall` preserves the original install options. ```sh brew update brew uninstall ipbtools/ipb/ipb brew install ipbtools/ipb/ipb ``` ### Homebrew HEAD The HEAD formula builds `main` from source. Select Xcode 27 beta for the build and install its CoreDevice package for runtime. A fully qualified formula name trusts only that formula: ```sh brew install --HEAD ipbtools/ipb/ipb ipb version # source VERSION plus macOS/CoreDevice versions ipb doctor # layered self-check, names the next step on failure ipb devices # then: ipb screenshot before.png; ipb tap 0.15 0.12; ipb home ``` ### Development source and local installation To build the current `main` source with Xcode 27 beta selected: ```sh git clone https://github.com/ipbtools/ipb.git cd ipb make install PREFIX="$HOME/.local" export PATH="$HOME/.local/bin:$PATH" ipb help ``` For an existing checkout, pull its selected branch and repeat `make install` with the same prefix. `command -v ipb` shows which copy your shell runs; a Homebrew copy and a manual copy can coexist and contain different code. ### Shell completion A zsh completion ships with the tool and is installed to `share/zsh/site-functions/_ipb`, which Homebrew links automatically — open a new shell and `ipb ` lists the commands with descriptions. `-s ` completes against the attached devices, offering both the UUIDs and the device names, each annotated with model, iOS version, transport and tunnel state: ``` $ ipb -s device uuid -- (iPhone 12 mini, iOS 27.0, wired, tunnel connected) -- (iPhone 13 Pro, iOS 27.0, localNetwork, tunnel disconnected) device name -- iPhone 12 mini, iOS 27.0 -- iPhone 13 Pro, iOS 27.0 ``` From a source checkout, add it to `fpath` yourself: ```sh fpath=(/path/to/ipb/completions $fpath) autoload -Uz compinit && compinit ``` Only zsh is provided; bash has no completion. ### Updating the running copy `ipb update` is host-only: it does not enumerate/select phones and needs no `-s`, regardless of how many devices are attached. It updates the running Homebrew install or source checkout. A manual-prefix install returns exit 2 with its exact reinstall prefix; it does not update another Homebrew copy. Source updates follow the checkout's configured branch. A Homebrew stable install uses `brew upgrade`; a `--HEAD` install is reinstalled from the refreshed `main` source while retaining its HEAD option. The command only updates the copy that is running. An older HEAD wrapper predating this fix needs a one-time `brew update` and `brew reinstall --HEAD ipbtools/ipb/ipb`, or the stable channel switch above. `make install PREFIX=/some/dir` produces the same layout without Homebrew: `bin/ipb`, the helpers in `libexec/` (including the optional AX backend), `share/ipb/VERSION`, `share/ipb/requirements-ax.txt`, `share/ipb/smoke_matrix.sh`, and `share/zsh/site-functions/_ipb`. ### Application elements (`ipb ui`) ```sh ipb -s ui ipb -s ui --json ``` Returns the application's actual AX child graph, text, logical-point rectangles and state. JSON includes `children`, `parentId` and `depth`; the text output is indented by depth. It needs an optional Python 3.11+ / pymobiledevice3 11.10.2 environment on the Mac, an existing USB pairing and Developer Mode. It starts no XCTest session or phone app. AX can merge text and omit backing containers: the tested Settings page gives AX 13 nodes versus XCTest 176. `ipb` preserves the graph returned by the service. Description-first text reads avoid the reproduced Bilibili rich-Label encoding failure. Other read failures remain explicit; timeout recovery on a fresh connection is not implemented. See [the UI guide](docs/ui.md) for setup, JSON fields, text policy, bounds and the AX/XCTest comparison. Availability depends on the [installation channel](#installation-channels). ### Agent tools (`ipb mcp`) v0.6.0 provides a bounded stdio MCP server: `ipb mcp`. Configure a client with the absolute ipb path and `args: ["mcp"]`. Python 3.11+ is required; set `IPB_MCP_PYTHON` if needed. AX tools retain the optional dependencies from `ipb ui`. Tools provide fresh compact native observations, exact element operations and explicit coordinate input. Every device tool requires a full CoreDevice UUID. Requests serialize across MCP servers sharing one state directory; manual CLI/mirror are outside that lock. Uncertain actions are never replayed. See the [MCP guide](docs/mcp.md) for tools, results, cancellation and persistent isolation. Device acceptance remains pending. ## Build ```sh make ``` The helper binary is written to: ```sh build/ipb-helper ``` ## Usage `ipb help` prints the commands grouped by what they do; `ipb help hid` prints the low-level HID report commands used for protocol work. Touch coordinates are normalized from top-left to bottom-right, in the `0..1` range. Pointer deltas are signed relative integers. ```sh bin/ipb help # grouped command list bin/ipb devices # physical devices: uuid, name, os, transport, tunnel bin/ipb device # the device the other commands would use bin/ipb tap 0.5 0.5 bin/ipb launch com.apple.Preferences bin/ipb open https://www.apple.com bin/ipb clipboard set "你好 🚀" && bin/ipb clipboard get bin/ipb text "你好 🚀" # focus a text field first; replaces the device clipboard bin/ipb ui --deep --json # native application hierarchy bin/ipb ui --deep --full-state --json # separate supplementalAX state/role (slower) bin/ipb ui hit-test --point 0.15 0.55 --json bin/ipb ui press --identifier Seven --json # Calculator; re-read to verify effect bin/ipb ui locate --label '7' --json # exact native label bin/ipb ui wait --identifier Seven --timeout 5 --json # bounded read-only wait bin/ipb ui input --class UISearchBarTextField --text Battery --replace-all --json # requires actual keyboard focus bin/ipb ui scroll-to-visible --identifier com.apple.settings.general --json # one native scroll, then observe bin/ipb displays --json bin/ipb capabilities --json bin/ipb support --json # static implementation inventory; no device query bin/ipb apps | bin/ipb ps | bin/ipb lock-state | bin/ipb orientation bin/ipb push local.txt /Documents/x.txt --app bin/ipb long 0.615 0.675 1.2 bin/ipb scroll 0.5 0.75 0 0.30 bin/ipb swipe 0.5 0.75 0.5 0.35 bin/ipb home bin/ipb recents bin/ipb power # side button: locks an on screen, wakes an off one bin/ipb screenshot build/current.png bin/ipb stream --dir frames --count 20 # live screen frames (JPEG), no DeviceHub bin/ipb mirror # interactive screen window (GUI session required) bin/ipb service-ids bin/ipb services bin/ipb service-id touchscreen bin/ipb reset-gesture bin/ipb pointer 0 0 bin/ipb scroll-report 0x501 0 0 bin/ipb scroll-gesture 0.5 0.5 0 -25 # trackpad-style scroll (pointer + phase sequence) bin/ipb abs-pointer 0.5 0.5 # place the cursor bin/ipb scroll-event 0 0 0 # raw probe: accepted, no device effect demonstrated bin/ipb vendor-defined 0 0 0 # raw probe: accepted, no device effect demonstrated bin/ipb key escape bin/ipb button 0x0c 0x40 bin/ipb raw com.apple.coredevice.feature.remote.universalhidservice cd_uhid_tap 0x101 0.5 0.5 ``` v0.5.0 includes locator, input, scroll-to-visible and explicit system-alert operations. See [the element guide](docs/ui.md) for exact selectors, paste prompts, `alert-press`, nonzero outcomes and the tested device/host boundary. ### Choosing a device With one device connected there is nothing to choose: `ipb` picks the single wired or tunnelled physical device. With several, name one with `-s` / `--device` (adb's `-s`, idb's `--udid`) or by exporting `DEVICE_ID`; the flag wins. ```sh bin/ipb -s tap 0.5 0.5 # the full CoreDevice UUID bin/ipb -s 1D533177 device # a unique prefix of one bin/ipb -s "12 mini" screenshot before.png # part of the device name or model export DEVICE_ID= # the default for this shell ``` A selector is matched most-specific-first — whole UUID, then UUID prefix, then a case-insensitive substring of the device name or marketing model. `xcrun devicectl --device` accepts none of these shorthands, so `ipb` resolves them itself against `devicectl list devices --json-output`; a full UUID is passed straight through and costs no enumeration. For device commands, a selector that matches nothing or more than one device exits 3 and lists what is attached. Host-only `help`, `version`, `update` and `service-ids` bypass device selection. `ipb devices` prints the same list, and `ipb device` prints the UUID the other commands would use. Device identity is the CoreDevice UUID, not the UDID: the 642.x `devicectl list devices` table view prints UDIDs, which the HID services reject. Useful runtime overrides: ```sh DEVICE_ID= # pick a device explicitly (-s overrides it) UHID_SERVICE_ID=auto # or a fixed id such as 0x101 UHID_SERVICE_FALLBACK=0x101 # opt in to a fixed id when descriptor discovery fails; unset = error DEVELOPER_DIR=/path/to/Xcode-beta.app/Contents/Developer # only needed for `make`; runtime uses the CoreDevice package DEVICECTL=/path/to/devicectl # defaults to the copy inside CoreDevice.framework IPB_HELPER=/path/to/ipb-helper HIDCTL_WAIT_MS=700 # settle time after each send HIDCTL_TIMEOUT_S=30 # watchdog for a single helper run ``` `UHID_SERVICE_ID` defaults to `auto`: the wrapper calls `connectedServiceDescriptors()` and selects the descriptor whose product is `CoreDevice touchscreen(nil)`. If discovery fails the command exits 3 unless `UHID_SERVICE_FALLBACK` is set. Exit codes from the helper: 0 ok, 1 a dispatched operation or the remote connection reported failure, 2 usage or local error, 3 CoreDeviceService refused the service socket (the CoreDevice error is printed), 4 the device tunnel is not connected, 5 watchdog timeout. On 4 the wrapper warms the tunnel once with `devicectl device info details` and retries; nothing has been sent to the device at that point. ### Literal text and device metadata `ipb text ` copies the exact UTF-8 argument to the device clipboard, then sends the captured Command+V held-key sequence. It is separate from `key`, whose output depends on the phone's input method. Focus an editable field first. The command replaces the device clipboard; it does not restore it or enable continuous clipboard sharing. Discovery fails before a clipboard change; copy failure prevents paste. A failed paste is not replayed. Exit 0 means copy and paste submission succeeded, **not** that the focused application accepted the text. Verify the resulting field. Chinese, emoji, spaces and punctuation were verified in iOS 27 Settings search with Pinyin active. iOS may ask the focused app to allow pasting from `dtpasteboardd`; `text` does not answer that prompt. Secure fields and applications that reject paste are not covered by that result. `ipb displays --json` and `ipb capabilities --json` return a `schemaVersion: 1` envelope with the resolved `deviceIdentifier`. Displays preserves Apple's `displays`, `orientation`, `backlightState`; capabilities preserves the advertised entries, sorted by `featureIdentifier`. Select the explicit primary display; the first entry need not be the phone screen. Query failure is an error, not an empty capability list. An advertised feature is not a guarantee that its next operation will work. `ipb support --json` is a separate static inventory of ipb's implementation and prerequisites. It does not select or query a device: advertisement is `unknown` and verification records are empty. Listed implementations are `unverified`; explicitly unimplemented operations are `unsupported`. `-s` and `DEVICE_ID` do not turn this into a device probe. The output has `kind="ipb.support"`, `contractVersion=1`; it is not a complete CLI command list or a claim of device availability. [Interface contract](docs/contract.md) describes its schema. For scripts, `IPB_ERROR_FORMAT=json` opts into a single `ipb.error` v1 document on handled Python AX failures. The nonzero exit code is preserved, and any complete native result is retained in its top-level `result` field. Default errors and successful schema 1/2 or text output stay unchanged. zsh setup/device-selection errors, native helpers, raw `text` and external abnormal termination are outside this initial coverage; a missing receipt is unknown, not permission to replay an action. See the [error contract](docs/contract.md) and [UI guide](docs/ui.md#opt-in-structured-errors-and-implementation-inventory). ### Live screen stream: `ipb stream` Streams the device screen without DeviceHub, without injecting any Apple process, and without any Apple-private entitlement. Frames are native-resolution baseline JPEG; only frames whose content actually changed are emitted, so a static screen yields ~1/s and a moving one ~40-57/s. ```sh bin/ipb stream --dir DIR [--count N] [--fps F] [--seconds S] bin/ipb stream --stdout # repeated [uint32 BE length][jpeg bytes] # live view (see the note on --framerate below) bin/ipb stream --stdout --seconds 60 \ | ffplay -fflags nobuffer -flags low_delay -f mjpeg -framerate 60 -i - ``` **Requires a GUI login session** (`CGGetActiveDisplayList` > 0), because in-process decoding creates a `CVDisplayLink`. It works with SIP enabled; it does *not* work over plain ssh — from ssh, run it in the console session with `open -a Terminal