Control a real USB-connected iPhone from Linux (no Mac, no paid developer account) and expose it to AI agents as MCP tools
Rust ai-agentautomationclaudeclaude-codedockeriosiphonelinuxmcpmcp-servermodel-context-protocolrustwebdriveragent
修复审查发现的问题:操作安全、超时与恢复、iPad 兼容、文档对齐 0.1.3、依赖安全更新 (#21)
Qinghe Li70d1a58a5277
diff --git a/.env.example b/.env.exampleindex 2bfe9d7..bc3b37f 100644--- a/.env.example+++ b/.env.example@@ -7,9 +7,11 @@ IMAGE=iphone-control:local# 数据目录:配对记录、Apple ID 会话和开发私钥、签好的 WDA、开发者镜像缓存、日志、锁屏密码。务必备份,不要提交DATA_DIR=./data-# 接了多台手机时指定要控制的那台;留空用第一台+# 固定控制哪台设备,设了就不能切换。留空为自动选:正在控制的那台一直用到它断开;+# 运行中可以用 `iphone-control select` 或 iphone_select_device 工具切换IPHONE_UDID=-# WDA 从没连上过、又要走 HID 后备路线时换算坐标用的屏幕尺寸(点);一般留空+# HID 后备路线换算坐标用的屏幕尺寸(点):WDA 不可用、又没有这台设备的尺寸记录时才用(从没连上过 WDA,或切到记录里没有尺寸的设备)。+# 不分设备,接多台时要小心;一般留空SCREEN_W=SCREEN_H=@@ -18,7 +20,7 @@ HTTP_PROXY=HTTPS_PROXY=NO_PROXY=localhost,127.0.0.1,::1-# 描述文件(免费账号 7 天有效)剩余不到几天时重签;每隔几小时检查一次+# 描述文件(免费账号 7 天有效)剩余不到几天时重签;每隔几小时检查一次(手机重新连上或切换设备后 1 分钟内也查一次)RESIGN_MIN_DAYS=2RESIGN_CHECK_HOURS=6# 手机离线超过几分钟推送提醒;0 表示不提醒@@ -33,11 +35,21 @@ BARK_KEY=# 高级# 自建 anisette 服务(默认用 Impactor 的第三方服务)ICTL_ANISETTE_URL=-# 开发者镜像下载地址(默认社区维护的 doronz88/DeveloperDiskImage);或指向自己从 Xcode 提取的目录+# 开发者镜像下载地址(默认社区维护的 doronz88/DeveloperDiskImage)ICTL_DDI_URL=+# 自己从 Xcode 提取的开发者镜像目录。设了就不下载,也不会删里面的文件;缺文件时报错说明缺哪个ICTL_DDI_DIR=# 守护进程是否自己拉起 usbmuxd。默认:以 root 运行(容器)时拉起,以普通用户运行时用系统的 usbmuxd 服务。# 以 root 从源码运行、宿主机又已有 usbmuxd 服务时设为 0# ICTL_MANAGE_USBMUXD=0+# 守护进程自己拉起 usbmuxd 时用的可执行文件,默认 usbmuxd+# ICTL_USBMUXD_BIN=/usr/sbin/usbmuxd+# 未签名 WDA 的路径。默认:容器里是 /usr/share/iphone-control/WDA-unsigned.ipa;从源码运行是数据目录的 wda/WDA-unsigned.ipa,首次签名前下载+# ICTL_WDA_UNSIGNED=/path/to/WDA-unsigned.ipa+# 数据目录和控制接口(同 --data-dir、--socket)。容器里不要改。要改时不能留空,守护进程、命令行和 MCP 要用同样的值。+# 默认:root 是 /var/lib/iphone-control 和 /run/iphone-control/ctl.sock;+# 普通用户是 $XDG_DATA_HOME/iphone-control(没设时 ~/.local/share/iphone-control)和 $XDG_RUNTIME_DIR/iphone-control/ctl.sock(没有 XDG_RUNTIME_DIR 时放在数据目录里)+# ICTL_DATA_DIR=/path/to/data+# ICTL_SOCKET=/path/to/ctl.sock# 日志级别(tracing EnvFilter 语法)# ICTL_LOG=info,ictl_wda::http=debugdiff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex b079fc7..c397dcc 100644--- a/.github/ISSUE_TEMPLATE/bug_report.yml+++ b/.github/ISSUE_TEMPLATE/bug_report.yml@@ -18,8 +18,8 @@ body:- type: inputid: deviceattributes:- label: Phone model and iOS version / 机型和 iOS 版本- placeholder: iPhone 15 Pro Max, iOS 27.0.1+ label: Device model and iOS version / 机型和 iOS 版本+ placeholder: iPhone 15 Pro Max, iOS 27.0.1 / iPad mini 5, iOS 26.6.1validations:required: true- type: dropdown@@ -28,15 +28,18 @@ body:label: How do you run it / 运行方式options:- Docker (compose)- - From source (systemd user service or manual)- - From source as root+ - Linux prebuilt binary+ - Linux from source (systemd user service or manual)+ - Linux from source as root+ - macOS prebuilt binary+ - macOS from sourcevalidations:required: true- type: inputid: versionattributes:label: Version or commit / 版本或提交- placeholder: v0.1.0, or the output of `git rev-parse --short HEAD`+ placeholder: v0.1.3, or the output of `git rev-parse --short HEAD`- type: textareaid: doctorattributes:diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.mdindex 0c9cb2c..40c7924 100644--- a/.github/PULL_REQUEST_TEMPLATE.md+++ b/.github/PULL_REQUEST_TEMPLATE.md@@ -4,7 +4,7 @@## How it was tested-- [ ] `cargo test --workspace`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --check` (per package)+- [ ] `cargo test --workspace --all-features`, `cargo clippy --workspace --all-targets --all-features -- -D warnings`, `cargo fmt --check` (per package)- [ ] On a real phone (model, iOS version, what you ran — e.g. `tests/device/run.py`):- [ ] Not needed (docs only, or no device-facing change)diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 733e9ed..beb2283 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -47,8 +47,9 @@ jobs:# vendor/ 是上游代码,不格式化;只检查本仓库的包- name: fmtrun: for p in ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done- - run: cargo clippy --workspace --all-targets --locked -- -D warnings- - run: cargo test --workspace --locked+ # --all-features:默认不编的 debug-cmds(调试子命令)也要能编译+ - run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings+ - run: cargo test --workspace --all-features --locked# macOS(Apple Silicon)上能编译、测试通过;格式和平台无关,上面已经查过macos:@@ -62,8 +63,9 @@ jobs:with:components: clippy- uses: Swatinem/rust-cache@v2- - run: cargo clippy --workspace --all-targets --locked -- -D warnings- - run: cargo test --workspace --locked+ # --all-features:默认不编的 debug-cmds(调试子命令)也要能编译+ - run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings+ - run: cargo test --workspace --all-features --locked# Cargo.toml 声明的最低版本(rust-version)要真能编译msrv:diff --git a/.gitignore b/.gitignoreindex b1fec04..b8bde24 100644--- a/.gitignore+++ b/.gitignore@@ -7,5 +7,7 @@*.mobileprovision*.pem*.ipa-!/docs/**.env+# tests/device/run.py 的虚拟环境和真机截图(截图里可能有个人信息)+.venv/+shots/diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0ce6277..c956016 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,31 @@ All notable changes to this project are documented here. The format is based on## [Unreleased]+### Security++- Updated the `zip` crate to 9.4.1 (from 8.6.0, and 2.6.1 in the vendored apple-codesign) for GHSA-m665-v7pm-7grj, GHSA-q7v9-x93c-xqv3, GHSA-hjqx-j4rw-g7xv, GHSA-9hj8-73fh-9963 and GHSA-8hxf-qr8p-62x4. iphone-control only unpacks the checksum-verified WebDriverAgent package from Appium, so the practical exposure was small.+- The documentation site's build tooling uses vite 6.4.5 and esbuild 0.25 (development dependencies only; the published site was not affected).++### Changed++- `ICTL_DDI_DIR` (a Developer Disk Image directory you extracted yourself) is never downloaded into or deleted from; missing files are reported by name. Only the default `ddi/` cache is cleared and downloaded again, and only after three failed *mounts* (tunnel errors no longer count).+- The `debug` subcommands are no longer built by default; build with `--features debug-cmds` to get them.+- Tool descriptions say that screenshots, `iphone_list_elements` and `iphone_wait_for` also unlock the phone when auto-unlock is configured, and that the HID fallback needs iOS 27.++### Fixed++- An action whose WebDriverAgent request was sent but whose connection then dropped, or whose response was incomplete, is no longer repeated over HID (a tap or text could happen twice). It now reports that the phone may already have done it.+- Calls to usbmuxd, lockdown, AMFI, misagent and installation_proxy have time limits, so a phone or usbmuxd that accepts a connection but never answers can no longer hang the daemon.+- Re-signing has an overall time limit (15 minutes) instead of staying "in progress" forever when Apple's servers or the install stall, and the Apple ID session check has one too. After the phone reconnects or another device is selected, re-signing is checked within a minute instead of waiting up to `RESIGN_CHECK_HOURS`. Finishing a re-sign for one device no longer tears down the session of a device selected meanwhile.+- When the phone is locked before its first unlock and WDA can't start, `status` keeps showing that the phone needs unlocking and retries every 20 seconds, instead of flipping back to "starting" and retrying every 10 seconds.+- A HID session that timed out while opening no longer leaves the screen media stream running on the phone (no auto-lock, icon stuck in the Dynamic Island).+- Cancelling an MCP call stops it: the remaining `iphone_batch` steps don't run, and a request still waiting for the device is dropped.+- `iphone_batch` stops if the controlled device changes while it runs (for example, the device is unplugged and another one is picked automatically).+- A newly started WebDriverAgent is only considered ready after its test plan has started, so a stale WDA still answering on the phone can't make it look ready early.+- `doctor` counts only iPhones, iPads and iPods as phones on USB; an Apple keyboard no longer passes the check.+- The system-alert check after an action is no longer skipped when the tapped element's text happens to contain the words "系统弹窗".+- Auto-unlock now also recognizes leftover WDA wait settings from an interrupted swipe or poll and restores the defaults.+## [0.1.3] - 2026-11-07### Upgrade notesdiff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.mdindex 329921f..ecdcb98 100644--- a/CHANGELOG.zh-CN.md+++ b/CHANGELOG.zh-CN.md@@ -6,6 +6,31 @@## [Unreleased]+### 安全++- `zip` 升级到 9.4.1(原来是 8.6.0,vendor 的 apple-codesign 里是 2.6.1),修复 GHSA-m665-v7pm-7grj、GHSA-q7v9-x93c-xqv3、GHSA-hjqx-j4rw-g7xv、GHSA-9hj8-73fh-9963、GHSA-8hxf-qr8p-62x4。iphone-control 只解压核对过 sha256 的 Appium 官方 WDA 包,实际受影响的可能很小。+- 文档站的构建工具改用 vite 6.4.5、esbuild 0.25(只是开发依赖,发布的网站不受影响)。++### 变更++- `ICTL_DDI_DIR`(自己提取的开发者镜像目录)不再往里下载,也不会删除里面的文件;缺文件时报出缺哪个。只有默认缓存 `ddi/` 在连续 3 次**挂载**失败后才清掉重新下载(建不起隧道不再计入)。+- `debug` 子命令默认不再编译,需要时用 `--features debug-cmds` 编译。+- 工具描述写明:配置了自动解锁时,截图、`iphone_list_elements`、`iphone_wait_for` 也会先解锁;HID 后备需要 iOS 27。++### 修复++- WebDriverAgent 请求已经发出、之后连接断开或响应不完整时,不再改用 HID 重做一遍(点击、输入可能执行两次),改为提示手机可能已经执行。+- 对 usbmuxd、lockdown、AMFI、misagent、installation_proxy 的调用都加了时限:手机或 usbmuxd 接了连接却不应答时,守护进程不会再卡死。+- 重签有总时限(15 分钟),苹果服务器或安装卡住时不再一直“正在重签”;Apple ID 会话检查也有时限。手机重新接上或切换设备后,1 分钟内就检查是否需要重签,不用等满 `RESIGN_CHECK_HOURS`。给一台设备重签完成时,不再拆掉期间切换过去的另一台的会话。+- 手机重启后还没解锁、WDA 起不来时,`status` 一直显示需要解锁手机,每 20 秒重试一次,不再在“正在启动”和它之间来回切、每 10 秒重试。+- 开启 HID 会话超时时,不再把屏幕媒体流留在手机上(不自动锁屏、灵动岛图标常驻)。+- 取消 MCP 调用后真的会停下:`iphone_batch` 剩下的步骤不再执行,还在排队等设备的请求也会放弃。+- `iphone_batch` 执行中控制的设备变了(例如拔掉后自动改控另一台)就停下。+- 新启动的 WebDriverAgent 要等测试计划开始后才算就绪,手机上残留的旧 WDA 不会让它提前被当成就绪。+- `doctor` 只把 iPhone、iPad、iPod 算作 USB 上的手机,接着苹果键盘时不再误报。+- 点到的元素文字里正好含“系统弹窗”时,操作后的弹窗检查不再被跳过。+- 自动解锁也能认出滑动、轮询中途被打断后残留的 WDA 等待设置,并恢复默认值。+## [0.1.3] - 2026-11-07### 升级注意事项diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex a63784c..39bda08 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -6,8 +6,8 @@ Most of the code comments, design documents and commit messages in this reposito## Before you start-- **Bugs:** include the phone model, iOS version, how you run it (container or source), and the output of `iphone-control doctor`, with private data removed. The [issue template](.github/ISSUE_TEMPLATE/bug_report.yml) asks for these.-- **Larger changes:** open an issue first. The key design decisions and their reasons are in [docs/decisions.md](docs/decisions.md); the regression cases every change must keep passing are in [docs/dev/roadmap.md](docs/dev/roadmap.md#必须覆盖的回归用例).+- **Bugs:** include the iPhone or iPad model, iOS version, how you run it (Docker, prebuilt binary or source; Linux or macOS), and the output of `iphone-control doctor`, with private data removed. The [issue template](.github/ISSUE_TEMPLATE/bug_report.yml) asks for these.+- **Larger changes:** open an issue first. The key design decisions and their reasons are in [docs/decisions.md](docs/decisions.md); the regression cases every change must keep passing are in [docs/dev/regression-cases.md](docs/dev/regression-cases.md).- **Security problems:** don't open an issue — see [SECURITY.md](SECURITY.md).## Building and testing without a phone@@ -15,8 +15,9 @@ Most of the code comments, design documents and commit messages in this repositoYou need Rust 1.88 or later (CI pins 1.99.1) and a C compiler. Everything except the device tests runs offline:```bash-cargo test --workspace --locked-cargo clippy --workspace --all-targets --locked -- -D warnings+# --all-features also builds the debug-cmds feature, as CI does+cargo test --workspace --all-features --locked+cargo clippy --workspace --all-targets --all-features --locked -- -D warnings# vendor/ is upstream code and isn't formatted; check only this repository's packages:for p in ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done```@@ -25,7 +26,7 @@ Or, without Rust installed:```bashdocker run --rm -v "$PWD":/src -w /src rust:1-trixie sh -c \- 'rustup component add clippy && cargo test --workspace --locked && cargo clippy --workspace --all-targets --locked -- -D warnings'+ 'rustup component add clippy && cargo test --workspace --all-features --locked && cargo clippy --workspace --all-targets --all-features --locked -- -D warnings'```Behind a firewall add `--network host -e HTTP_PROXY -e HTTPS_PROXY` (`idevice` is a git dependency). `cargo test -p <one crate>` can fail to compile `plume_store` because of feature unification; test the whole workspace instead.@@ -42,14 +43,14 @@ python3 -m venv .venv && .venv/bin/pip install -r tests/device/requirements.txt.venv/bin/python tests/device/run.py '[["iphone_launch_app", {"app": "设置"}], ["iphone_screenshot", {}]]'```-On macOS, the full checklist (setup, `debug` checks, coexistence with Finder, reconnect) is in [docs/dev/macos-verification.md](docs/dev/macos-verification.md).+`run.py` prints every result with its wall time and saves screenshots to `./shots`. Set `MCP_CMD` for a source install (for example `MCP_CMD="iphone-control mcp"`). Please mention in the pull request what you ran on which device and iOS version.-It prints every result with its wall time and saves screenshots to `./shots`. Set `MCP_CMD` for a source install (for example `MCP_CMD="iphone-control mcp"`). Please mention in the pull request what you ran on which device and iOS version.+On macOS, the full checklist (setup, `debug` checks, coexistence with Finder, reconnect) is in [docs/dev/macos-verification.md](docs/dev/macos-verification.md).Notes:- Wait until `iphone-control status` says 就绪 (ready) before calling tools after a restart. Restarting the daemon several times in quick succession can make the phone ask for the passcode to enable UI automation again.-- Never run two daemons, or the hidden `iphone-control debug …` diagnostics, against the same phone at once: only one usbmuxd and one XCTest session can own it.+- Never run two daemons, or the hidden `iphone-control debug …` diagnostics, against the same phone at once: only one usbmuxd and one XCTest session can own it. `debug` is not compiled by default; build it with `cargo build -p iphone-control --features debug-cmds` or `cargo install --path apps/iphone-control --locked --features debug-cmds`.- Don't automate anything that sends messages, pays, deletes data or changes account or privacy settings in tests.### Adding an element-tree fixture@@ -77,13 +78,15 @@ Notes:## Documentation site-The user guide at [derrors.github.io/iphone-control](https://derrors.github.io/iphone-control/) is a VitePress site in [`website/`](website/) (Chinese at the root, English under `en/`; keep both in step). Preview it with `cd website && pnpm install && pnpm docs:dev`. [`docs.yml`](.github/workflows/docs.yml) builds it on every pull request (dead links fail the build) and deploys it from `main`.+The user guide at [derrors.github.io/iphone-control](https://derrors.github.io/iphone-control/) is a VitePress site in [`website/`](website/) (Chinese at the root, English under `en/`; keep both in step). Preview it with `cd website && pnpm install && pnpm docs:dev`. [`docs.yml`](.github/workflows/docs.yml) builds it on pull requests and pushes to `main` that change `website/` (dead links fail the build) and deploys it from `main`. Changes elsewhere, including `docs/`, don't trigger it.## Releasing (maintainers)1. Move the *Unreleased* entries in [CHANGELOG.md](CHANGELOG.md) and [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md) under `## [x.y.z] - YYYY-MM-DD` and update the compare links at the bottom. Both files need the section — the release notes are built from the two (English, then Chinese) and the workflow fails if either is missing. Keep entries short: one line per user-visible change, no implementation details.2. Set `version` in the root `Cargo.toml` (`[workspace.package]`) and run `cargo check --workspace` to update `Cargo.lock`.-3. Commit, tag `vx.y.z`, push the tag. [`release.yml`](.github/workflows/release.yml) builds the amd64/arm64 images on native runners and pushes them to `ghcr.io/derrors/iphone-control` (tags `x.y.z`, `x.y`, `latest`; pre-releases such as `v0.2.0-rc.1` only get their own tag), builds the Linux binaries (`iphone-control-vx.y.z-linux-x86_64.tar.gz`, `…-linux-aarch64.tar.gz`), and creates the GitHub release from the two changelog sections. The macOS binary (`…-macos-arm64.tar.gz`) is built afterwards and uploaded to the release; if GitHub has no macOS runner available the job is cancelled after about 15 minutes — re-run just that job.-4. First release only: make the ghcr package public (*Package settings → Change visibility*) — new packages start private.+3. Update `V=vx.y.z` in `README.md`, `README.zh-CN.md`, `website/deploy/macos.md` and `website/en/deploy/macos.md`, and the pinned image examples (`:x.y.z`) in `website/deploy/docker.md` and `website/en/deploy/docker.md`.+4. Commit, tag `vx.y.z`, push the tag. [`release.yml`](.github/workflows/release.yml) builds the amd64/arm64 images on native runners and pushes them to `ghcr.io/derrors/iphone-control` (tags `x.y.z`, `x.y`, `latest`; pre-releases such as `v0.2.0-rc.1` only get their own tag), builds the Linux binaries (`iphone-control-vx.y.z-linux-x86_64.tar.gz`, `…-linux-aarch64.tar.gz`), and creates the GitHub release from the two changelog sections. The macOS binary (`…-macos-arm64.tar.gz`) is built afterwards and uploaded to the release; if GitHub has no macOS runner available the job is cancelled after about 15 minutes — re-run just that job.+5. Update Glama: on glama.ai, the build steps under this server's *Admin → Dockerfile* pin the version. Change it and rebuild.+6. First release only: make the ghcr package public (*Package settings → Change visibility*) — new packages start private.By contributing you agree that your contributions are licensed under the MIT license, except for changes to vendored files, which stay under their original licenses.diff --git a/Cargo.lock b/Cargo.lockindex b21adda..43b6b10 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -225,7 +225,7 @@ dependencies = ["xml-rs","yasna","zeroize",- "zip 2.6.1",+ "zip","zip_structs",]@@ -274,15 +274,6 @@ dependencies = ["xz2",]-[[package]]-name = "arbitrary"-version = "1.5.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed"-dependencies = [- "derive_arbitrary",-]-[[package]]name = "arrayvec"version = "0.7.8"@@ -1188,17 +1179,6 @@ version = "0.5.9"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"-[[package]]-name = "derive_arbitrary"-version = "1.5.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1b034bd7d5f032402a2479444dcc6f74e36a03f31854d41680fb240ef682a1ac"-dependencies = [- "proc-macro2",- "quote",- "syn 3.0.9",-]-[[package]]name = "des"version = "0.8.1"@@ -2030,7 +2010,7 @@ dependencies = ["thiserror 2.0.21","tracing","uuid",- "zip 8.6.0",+ "zip",][[package]]@@ -2656,6 +2636,18 @@ dependencies = ["tempfile",]+[[package]]+name = "nix"+version = "0.31.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"+dependencies = [+ "bitflags 2.13.2",+ "cfg-if",+ "cfg_aliases",+ "libc",+]+[[package]]name = "nom"version = "7.1.3"@@ -4945,9 +4937,9 @@ dependencies = [[[package]]name = "typed-path"-version = "0.12.4"+version = "0.13.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "54ec2755506471f54baf5e4bb5499d8e510cc1caf271270e778a736bd2d7336c"+checksum = "9ce898823d8cd0f028662d2f349694b1af0a5cc9be83f1d213a00d3147445e1e"[[package]]name = "typenum"@@ -5736,30 +5728,19 @@ dependencies = [[[package]]name = "zip"-version = "2.6.1"+version = "9.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744"-dependencies = [- "arbitrary",- "crc32fast",- "crossbeam-utils",- "flate2",- "indexmap",- "memchr",- "zopfli",-]--[[package]]-name = "zip"-version = "8.6.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"+checksum = "23f17fbc870bfac28c6228aed7d6e6df352e26bf7015c4313727e16a7a01ce5e"dependencies = ["crc32fast","flate2",+ "getrandom 0.4.3","indexmap",+ "libc","memchr",+ "nix","typed-path",+ "windows-sys 0.61.2","zopfli",]diff --git a/Cargo.toml b/Cargo.tomlindex 1628ea7..d54f28f 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -61,7 +61,7 @@ base64 = "=0.23.1"anyhow = "=1.0.104"plist = "=1.10.3"uuid = { version = "=1.26.1", features = ["v4"] }-zip = { version = "=8.6.0", default-features = false, features = ["deflate"] }+zip = { version = "=9.4.1", default-features = false, features = ["deflate"] }regex = "=1.13.1"libc = "=0.2.191"sha2 = "=0.10.9"diff --git a/README.md b/README.mdindex 688c9c1..a8ba372 100644--- a/README.md+++ b/README.md@@ -4,14 +4,14 @@</a><p align="center">- Let an AI agent operate a real iPhone plugged into a Linux machine or a Mac — one Rust binary, no Xcode, no paid developer account, no jailbreak.+ Let an AI agent operate a real iPhone or iPad plugged into a Linux machine or a Mac — one Rust binary, no Xcode, no paid developer account, no jailbreak.</p><p align="center"><a href="https://github.com/Derrors/iphone-control/releases/latest"><img src="https://img.shields.io/github/v/release/Derrors/iphone-control?style=flat" alt="Release"></a><img src="https://img.shields.io/badge/iOS-17%2B-black?style=flat&logo=apple" alt="iOS"><img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-0E7490?style=flat" alt="Platform: Linux | macOS">- <img src="https://img.shields.io/badge/MCP-15%20tools-8A2BE2?style=flat" alt="MCP">+ <img src="https://img.shields.io/badge/MCP-17%20tools-8A2BE2?style=flat" alt="MCP"><a href="Cargo.toml"><img src="https://img.shields.io/badge/Rust-1.88%2B-CE422B?style=flat&logo=rust&logoColor=white" alt="Rust"></a><a href="LICENSE"><img src="https://img.shields.io/github/license/Derrors/iphone-control?style=flat" alt="License"></a><a href="https://m8ven.ai/mcp/derrors-iphone-control-1pcmse?s=readme"><img src="https://m8ven.ai/badge/mcp/derrors-iphone-control-1pcmse?variant=verified" alt="M8ven verified"></a>@@ -43,7 +43,7 @@ iphone-control does it all in **one Rust binary** on Linux or macOS, built on [i<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="website/public/architecture-dark.svg">- <img src="website/public/architecture-light.svg" alt="Architecture: an MCP client talks to iphone-control mcp over stdio, which talks to the daemon over a Unix socket; the daemon drives the iPhone over USB through WebDriverAgent, with CoreDevice HID as fallback" width="900">+ <img src="website/public/architecture-light.svg" alt="Architecture: an MCP client talks to iphone-control mcp over stdio, which talks to the daemon over a Unix socket; the daemon drives the iPhone or iPad over USB through WebDriverAgent, with CoreDevice HID as fallback" width="900"></picture></p>@@ -64,7 +64,7 @@ iphone-control does it all in **one Rust binary** on Linux or macOS, built on [i## Quick Start-You need an iPhone on iOS 17+ connected by a **data** cable, a free Apple ID (use a dedicated one), and a Linux host with Docker or an Apple Silicon Mac.+You need an iPhone or iPad on iOS 17+ connected by a **data** cable, a free Apple ID (use a dedicated one), and a Linux host with Docker or an Apple Silicon Mac.**Linux (Docker)**@@ -107,6 +107,8 @@ More: [step-by-step guide](https://derrors.github.io/iphone-control/en/guide/get| `iphone_open_url` | Open a URL or URL scheme || `iphone_wait_for` | Wait until some text appears instead of polling with screenshots || `iphone_batch` | Run up to 20 steps in one call, stopping at the first error |+| `iphone_list_devices` | Every iPhone/iPad on USB; marks the one being controlled |+| `iphone_select_device` | Switch to another device, or back to automatic choice |Action tools accept `then: "elements" | "screenshot"` to return the screen after the action. Screenshot pixels are tap coordinates, so the agent can tap what it sees. Games, maps and video players draw their own UI and have no element tree — use screenshots and coordinates there. Full parameters: [docs/tools.md](docs/tools.md).@@ -116,24 +118,31 @@ Run them as `docker exec -it iphone-control iphone-control <command>`, or direct| Command | What it does || --- | --- |+| `daemon` | The long-running daemon: the container's entry point; on a source install or macOS you start it yourself |+| `mcp` | The MCP server; your AI client starts it || `status` | Daemon state, time left on the signing profile, recent log || `doctor` | Layer-by-layer health check with a fix for each failure || `setup` | Guided setup; re-run any time || `login` | Sign in to the Apple ID again when the session expires |+| `sign` | Sign and install WebDriverAgent now || `resign [--force]` | Re-sign WebDriverAgent if it expires soon (or now) || `passcode set\|clear` | Turn auto-unlock on or off for a device (passcodes are kept per device) |+| `unlock-reset` | Turn auto-unlock back on after it was disabled || `devices` / `select <UDID\|name\|auto>` | List connected devices / switch which one is controlled || `notify-test [event]` | Send test notifications || `mcp-config` | Print the command that registers the MCP server |+| `wda-bridge [--port]` | Expose WebDriverAgent on 127.0.0.1 for other tools; stop it when done |-Upgrade with `git pull && docker compose up -d --build` (or `docker compose pull` for the prebuilt image). Settings live in `.env` — see [configuration](https://derrors.github.io/iphone-control/en/guide/configuration). All state lives in `data/`: pairing records, the Apple ID session and signing key, and the passcode if auto-unlock is on. **Back it up; never commit or share it.**+All commands and options: [CLI reference](https://derrors.github.io/iphone-control/en/guide/cli).++Upgrade with `git pull && docker compose up -d --build` (or `docker compose pull && docker compose up -d --no-build` for the prebuilt image); for the binary and macOS, see [Source / binary](https://derrors.github.io/iphone-control/en/deploy/source#upgrade) and [macOS](https://derrors.github.io/iphone-control/en/deploy/macos#upgrade). Read the upgrade notes in the [changelog](CHANGELOG.md) first. Settings live in `.env` — see [configuration](https://derrors.github.io/iphone-control/en/guide/configuration). All state lives in `data/`: pairing records, the Apple ID session and signing key, and the passcode if auto-unlock is on. **Back it up; never commit or share it.**## Documentation| | || --- | --- || Guide | [What is it](https://derrors.github.io/iphone-control/en/guide/what-is-iphone-control) · [Limitations](https://derrors.github.io/iphone-control/en/guide/what-is-iphone-control#limitations) · [Getting started](https://derrors.github.io/iphone-control/en/guide/getting-started) · [AI clients](https://derrors.github.io/iphone-control/en/guide/mcp-clients) · [Tools](https://derrors.github.io/iphone-control/en/guide/tools) |-| Usage | [Configuration](https://derrors.github.io/iphone-control/en/guide/configuration) · [Notifications](https://derrors.github.io/iphone-control/en/guide/notifications) · [Auto-unlock](https://derrors.github.io/iphone-control/en/guide/auto-unlock) |+| Usage | [Configuration](https://derrors.github.io/iphone-control/en/guide/configuration) · [CLI](https://derrors.github.io/iphone-control/en/guide/cli) · [Several devices](https://derrors.github.io/iphone-control/en/guide/multi-device) · [Notifications](https://derrors.github.io/iphone-control/en/guide/notifications) · [Auto-unlock](https://derrors.github.io/iphone-control/en/guide/auto-unlock) || Deployment | [Docker](https://derrors.github.io/iphone-control/en/deploy/docker) · [Source / binary](https://derrors.github.io/iphone-control/en/deploy/source) · [macOS](https://derrors.github.io/iphone-control/en/deploy/macos) · [Data and backups](https://derrors.github.io/iphone-control/en/deploy/backup) || Problems | [FAQ](https://derrors.github.io/iphone-control/en/troubleshoot/faq) · [Troubleshooting](docs/troubleshooting.md) · [Issues](https://github.com/Derrors/iphone-control/issues) || Security | [SECURITY.md](SECURITY.md): what is stored, who can reach it, reporting vulnerabilities |diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 5b5e9a5..e5072f6 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -4,14 +4,14 @@</a><p align="center">- 让 AI agent 操作一台接在 Linux 或 Mac 上的真实 iPhone:一个 Rust 二进制,不需要 Xcode,不需要付费开发者账号,不越狱。+ 让 AI agent 操作一台接在 Linux 或 Mac 上的真实 iPhone 或 iPad:一个 Rust 二进制,不需要 Xcode,不需要付费开发者账号,不越狱。</p><p align="center"><a href="https://github.com/Derrors/iphone-control/releases/latest"><img src="https://img.shields.io/github/v/release/Derrors/iphone-control?style=flat" alt="Release"></a><img src="https://img.shields.io/badge/iOS-17%2B-black?style=flat&logo=apple" alt="iOS"><img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-0E7490?style=flat" alt="平台:Linux | macOS">- <img src="https://img.shields.io/badge/MCP-15%20tools-8A2BE2?style=flat" alt="MCP">+ <img src="https://img.shields.io/badge/MCP-17%20tools-8A2BE2?style=flat" alt="MCP"><a href="Cargo.toml"><img src="https://img.shields.io/badge/Rust-1.88%2B-CE422B?style=flat&logo=rust&logoColor=white" alt="Rust"></a><a href="LICENSE"><img src="https://img.shields.io/github/license/Derrors/iphone-control?style=flat" alt="License"></a><a href="https://m8ven.ai/mcp/derrors-iphone-control-1pcmse?s=readme"><img src="https://m8ven.ai/badge/mcp/derrors-iphone-control-1pcmse?variant=verified" alt="M8ven 已验证"></a>@@ -43,7 +43,7 @@ iphone-control 在 Linux 或 macOS 上用**一个 Rust 二进制**把这些事<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="website/public/architecture-dark.svg">- <img src="website/public/architecture-light.svg" alt="架构:MCP 客户端经 stdio 调用 iphone-control mcp,再经 Unix socket 交给守护进程;守护进程经 USB 用 WebDriverAgent 操作 iPhone,CoreDevice HID 作为后备" width="900">+ <img src="website/public/architecture-light.svg" alt="架构:MCP 客户端经 stdio 调用 iphone-control mcp,再经 Unix socket 交给守护进程;守护进程经 USB 用 WebDriverAgent 操作 iPhone 或 iPad,CoreDevice HID 作为后备" width="900"></picture></p>@@ -64,7 +64,7 @@ iphone-control 在 Linux 或 macOS 上用**一个 Rust 二进制**把这些事## 快速开始-需要一部 iOS 17 以上的 iPhone 和能**传数据**的线、一个免费 Apple ID(建议专门注册一个),以及一台装了 Docker 的 Linux 主机或一台 Apple Silicon 的 Mac。+需要一部 iOS 17 以上的 iPhone 或 iPad 和能**传数据**的线、一个免费 Apple ID(建议专门注册一个),以及一台装了 Docker 的 Linux 主机或一台 Apple Silicon 的 Mac。**Linux(Docker)**@@ -107,8 +107,10 @@ iphone-control mcp-config # 打印 `claude mcp add` 命令,复制运行| `iphone_open_url` | 打开链接或 URL Scheme || `iphone_wait_for` | 等某段文字出现,代替反复截图 || `iphone_batch` | 一次执行最多 20 步,出错就停 |+| `iphone_list_devices` | 列出 USB 上接着的 iPhone/iPad,标出正在控制哪台 |+| `iphone_select_device` | 改为控制另一台,或改回自动选 |-操作类工具可以带 `then: "elements" | "screenshot"`,顺带返回操作后的界面。截图的像素就是点击坐标,agent 看到哪里就能点哪里。游戏、地图、视频自己绘制界面,没有元素树,只能看截图按坐标操作。完整参数见 [docs/tools.md](docs/tools.md)。+操作类工具可以带 `then: "elements" | "screenshot"`,顺带返回操作后的界面。截图的像素就是点击坐标,agent 看到哪里就能点哪里。游戏、地图、视频自己绘制界面,没有元素树,只能看截图按坐标操作。完整参数见 [docs/tools.md](docs/tools.md)(英文)。## 常用命令@@ -116,24 +118,31 @@ iphone-control mcp-config # 打印 `claude mcp add` 命令,复制运行| 命令 | 作用 || --- | --- |+| `daemon` | 常驻守护进程:容器的入口;从源码运行和 macOS 上要自己启动 |+| `mcp` | MCP 服务,由 AI 客户端拉起 || `status` | 守护进程状态、描述文件还剩多久、最近日志 || `doctor` | 逐层诊断,每项失败都给出修复办法 || `setup` | 安装向导,随时可以重新运行 || `login` | Apple ID 会话失效时重新登录 |+| `sign` | 立即签名并安装 WebDriverAgent || `resign [--force]` | 快过期才重签 WebDriverAgent(或立即重签) || `passcode set\|clear` | 开启或关闭一台设备的自动解锁(密码按设备分开存) |+| `unlock-reset` | 自动解锁被停用后恢复 || `devices` / `select <UDID\|设备名\|auto>` | 列出接着的设备 / 切换控制哪一台 || `notify-test [事件]` | 发送测试通知 || `mcp-config` | 打印注册 MCP 的命令 |+| `wda-bridge [--port]` | 把 WebDriverAgent 桥接到 127.0.0.1 给别的工具用,用完就停 |-升级:`git pull && docker compose up -d --build`(用预构建镜像时改为 `docker compose pull`)。配置写在 `.env`,见[配置说明](https://derrors.github.io/iphone-control/guide/configuration)。所有状态都在 `data/`:配对记录、Apple ID 会话和签名私钥,开启自动解锁时还有锁屏密码。**要备份,不要提交或分享。**+全部命令和参数见[命令行](https://derrors.github.io/iphone-control/guide/cli)。++升级:`git pull && docker compose up -d --build`(用预构建镜像时改为 `docker compose pull && docker compose up -d --no-build`);二进制和 macOS 见[从源码 / 二进制](https://derrors.github.io/iphone-control/deploy/source#升级)、[macOS](https://derrors.github.io/iphone-control/deploy/macos#升级)。升级前先看[更新日志](CHANGELOG.zh-CN.md)里的升级注意事项。配置写在 `.env`,见[配置说明](https://derrors.github.io/iphone-control/guide/configuration)。所有状态都在 `data/`:配对记录、Apple ID 会话和签名私钥,开启自动解锁时还有锁屏密码。**要备份,不要提交或分享。**## 文档| | || --- | --- || 入门 | [什么是 iphone-control](https://derrors.github.io/iphone-control/guide/what-is-iphone-control) · [限制](https://derrors.github.io/iphone-control/guide/what-is-iphone-control#限制) · [快速开始](https://derrors.github.io/iphone-control/guide/getting-started) · [接入 AI 客户端](https://derrors.github.io/iphone-control/guide/mcp-clients) · [工具一览](https://derrors.github.io/iphone-control/guide/tools) |-| 使用 | [配置](https://derrors.github.io/iphone-control/guide/configuration) · [通知](https://derrors.github.io/iphone-control/guide/notifications) · [自动解锁](https://derrors.github.io/iphone-control/guide/auto-unlock) |+| 使用 | [配置](https://derrors.github.io/iphone-control/guide/configuration) · [命令行](https://derrors.github.io/iphone-control/guide/cli) · [多台设备](https://derrors.github.io/iphone-control/guide/multi-device) · [通知](https://derrors.github.io/iphone-control/guide/notifications) · [自动解锁](https://derrors.github.io/iphone-control/guide/auto-unlock) || 安装 | [Docker](https://derrors.github.io/iphone-control/deploy/docker) · [从源码 / 二进制](https://derrors.github.io/iphone-control/deploy/source) · [macOS](https://derrors.github.io/iphone-control/deploy/macos) · [数据与备份](https://derrors.github.io/iphone-control/deploy/backup) || 问题 | [常见问题](https://derrors.github.io/iphone-control/troubleshoot/faq) · [排错(英文)](docs/troubleshooting.md) · [Issues](https://github.com/Derrors/iphone-control/issues) || 安全 | [SECURITY.md](SECURITY.md):存了什么、谁能访问、怎么报告漏洞 |diff --git a/SECURITY.md b/SECURITY.mdindex b1274cf..a5a5c55 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -12,21 +12,21 @@ iphone-control is, by design, a remote control for a phone. Anyone who can talk| Asset | Where | Who can reach it ||---|---|---|-| Phone control (taps, typing, screenshots, apps) | Control socket: `/run/iphone-control/ctl.sock` inside the container, `$XDG_RUNTIME_DIR/iphone-control/ctl.sock` for a source install; mode 0600 | Root on the host; anyone who can `docker exec` into the container; the user running a source install |+| Phone control (taps, typing, screenshots, apps) | Control socket: `/run/iphone-control/ctl.sock` inside the container, `$XDG_RUNTIME_DIR/iphone-control/ctl.sock` for a source install on Linux, `~/.local/share/iphone-control/ctl.sock` on macOS; mode 0600 | Root on the host; anyone who can `docker exec` into the container; the user running a source install or the macOS binary || WebDriverAgent (no authentication) | On the phone, reached through usbmuxd; nothing listens on the network unless you run `wda-bridge` | With `wda-bridge`: **every local user** on the host, because the container uses host networking. Browsers are blocked by a Host-header check (DNS rebinding), other local processes are not || Apple ID session tokens, development signing key and certificate | `account/` in the data directory (0700, key 0600) | Whoever can read the data directory. The Apple ID password itself is never stored |-| Pairing records | `lockdown/` in the data directory (container) or the system's `/var/lib/lockdown` | Root on the host. A pairing record lets its holder talk to the phone over USB without another *Trust* prompt |-| Lock-screen passcode | `secrets/passcode` in the data directory (0600), **plain text**, only if you ran `passcode set` | Whoever can read the data directory |+| Pairing records | `lockdown/` in the data directory (container), the system's `/var/lib/lockdown` (source install on Linux) or `/var/db/lockdown` (macOS, shared with Finder) | Root on the host. A pairing record lets its holder talk to the phone over USB without another *Trust* prompt |+| Lock-screen passcodes | `secrets/passcodes/<UDID>` in the data directory (0600), one file per device, **plain text**, only if you ran `passcode set`. A `secrets/passcode` file from an older version is moved to the device's file when exactly one device is connected, and stays where it is until then | Whoever can read the data directory || Notification credentials (Bark key, Telegram token) | `.env` or `~/.config/iphone-control/env` | Whoever can read that file |-The data directory is `./data` next to `compose.yaml` for the container (root-owned, mode 0700) and `~/.local/share/iphone-control` for a source install.+The data directory is `./data` next to `compose.yaml` for the container (root-owned, mode 0700) and `~/.local/share/iphone-control` for a source install and on macOS.## Design choices that limit exposure- No network listener by default. WebDriverAgent is reached through usbmuxd; `wda-bridge` only binds 127.0.0.1, only forwards requests whose Host header is a loopback name, and is meant to be stopped after use.- The control socket is a Unix socket with mode 0600, not TCP.- The container is not `privileged`: it is only allowed USB character devices (major 189), and the tunnel to the phone uses a user-space TCP stack, so no network interface or routing changes on the host.-- Auto-unlock is off by default. When enabled, it stops for good after a single wrong attempt (it writes a stop marker before entering the second digit) and sends a notification; it never retries a passcode that might be wrong. It does not work before the first unlock after a reboot (BFU) — that always needs a person.+- Auto-unlock is off by default. When enabled, it stops for good after a single wrong attempt (it writes a stop marker, `logs/UNLOCK-DISABLED`, before entering the second digit) and sends a notification; it never retries a passcode that might be wrong. The marker is global: a failure on one device stops auto-unlock on all of them until you run `unlock-reset`. It does not work before the first unlock after a reboot (BFU) — that always needs a person.- Dependencies are pinned to exact versions, `Cargo.lock` is committed, base images are pinned by digest, and the WebDriverAgent download is checked against a sha256. CI runs gitleaks on every push.## Known risks and recommendationsdiff --git a/THIRD_PARTY.md b/THIRD_PARTY.mdindex 31c2edc..b9c717c 100644--- a/THIRD_PARTY.md+++ b/THIRD_PARTY.md@@ -7,7 +7,7 @@| [idevice](https://github.com/jkcoxson/idevice) | 上游 master `89702099`(0.1.68 之后、未发版) | MIT | git 依赖,`[patch.crates-io]` | 无(0.1.68 的 cryptexd install 会挂住;发版后换回 crates.io) || [jktcp](https://crates.io/crates/jktcp) | 0.1.8(间接) | MIT | crates.io | 无 || [rmcp](https://github.com/modelcontextprotocol/rust-sdk) | 3.8.0 | Apache-2.0(部分历史代码 MIT) | crates.io | 无 |-| [apple-codesign](https://github.com/indygreg/apple-platform-rs) | 0.29.0(取自 Impactor `3rdparty/apple-codesign-0.29.0`) | MPL-2.0 | `vendor/apple-codesign`,`[patch.crates-io]` | Impactor 的 0o755 权限补丁(上游提交 428b42f);本仓库删掉了上游的 `tests/`、`docs/`、`Cargo.lock`、`Cargo.toml.orig`,Cargo.toml 去掉 `[[test]]` 目标,源码未改 |+| [apple-codesign](https://github.com/indygreg/apple-platform-rs) | 0.29.0(取自 Impactor `3rdparty/apple-codesign-0.29.0`) | MPL-2.0 | `vendor/apple-codesign`,`[patch.crates-io]` | Impactor 的 0o755 权限补丁(上游提交 428b42f);本仓库删掉了上游的 `tests/`、`docs/`、`src/testdata/`(单元测试的证书和密钥样例)、`Cargo.lock`、`Cargo.toml.orig`,Cargo.toml 去掉 `[[test]]` 目标、`zip` 依赖从 2.x 升到 9.4.1(修安全告警;只有公证功能用它写 zip,API 兼容),源码未改(因此 vendor 里的单元测试不能运行,本仓库也不跑它们) || [Impactor](https://github.com/claration/impactor) `plume_core` | v2.7.2(提交 b13d99559febd63e3710dfdd0ef8cdd78d10ae13) | MPL-2.0 | `vendor/plume_core` | 源码未改;Cargo.toml 把 workspace 继承展开成显式版本、修正 omnisette 路径;reqwest 用 `rustls-no-provider`(不编 aws-lc-rs);omnisette 改为 `default-features = false, features = ["remote-anisette", "remote-anisette-v3"]` || Impactor `plume_store` | 同上 | MIT | `vendor/plume_store` | 源码未改;Cargo.toml 展开 workspace 继承 || Impactor `omnisette` | 同上 | MPL-2.0 | `vendor/omnisette` | `src/lib.rs` 加了 `anisette_url_v3()`/`set_anisette_url_v3()`(原来 v3 地址没有 setter,自建 anisette 服务配不进去;改动处有注释,文件仍是 MPL-2.0);Cargo.toml 展开 workspace 继承;reqwest 用 `rustls-no-provider`;本地 anisette(StoreServicesCore,要苹果 Android 版的 `libstoreservicescore.so` 和没有许可证声明的 git 依赖 `android-loader`)改成可选 feature `local-anisette`,默认 feature 里保留与上游一致,本项目不启用(只用远程 anisette v3) |@@ -20,4 +20,4 @@因为不启用 omnisette 的默认 feature,AGPL-3.0 的过程宏 `remove-async-await` 和没有许可证声明的 `android-loader`/`sysv64` 都不会被编译。-完整的传递依赖许可证清单由 cargo-about 0.9.3 按 `Cargo.lock` 生成(配置 `docker/about.toml`),随镜像放在 `/usr/share/doc/iphone-control/THIRD_PARTY_LICENSES.html`。vendor 组件的许可证另放在 `/usr/share/licenses/<组件>/`(plume_store 的 MIT 许可证在 `/usr/share/licenses/plume_store/LICENSE`),WDA 的在 `/usr/share/licenses/WebDriverAgent/`。+完整的传递依赖许可证清单由 cargo-about 0.9.3 按 `Cargo.lock` 生成(配置 `docker/about.toml`),随镜像放在 `/usr/share/doc/iphone-control/THIRD_PARTY_LICENSES.html`。vendor 组件的许可证另放在 `/usr/share/licenses/<组件>/`(plume_store 的 MIT 许可证在 `/usr/share/licenses/plume_store/LICENSE`),WDA 的在 `/usr/share/licenses/WebDriverAgent/`。这些只随镜像分发:预编译二进制的压缩包只带 `LICENSE` 和本文件。diff --git a/apps/iphone-control/Cargo.toml b/apps/iphone-control/Cargo.tomlindex e8ef47e..58f49f8 100644--- a/apps/iphone-control/Cargo.toml+++ b/apps/iphone-control/Cargo.toml@@ -14,7 +14,7 @@ ictl-daemon.workspace = trueictl-device.workspace = trueictl-mcp.workspace = trueictl-sign.workspace = true-ictl-wda.workspace = true+ictl-wda = { workspace = true, optional = true }clap.workspace = truetokio.workspace = trueanyhow.workspace = true@@ -22,3 +22,8 @@ rustls.workspace = trueserde_json.workspace = truetracing.workspace = truetracing-subscriber.workspace = true++[features]+# `iphone-control debug …` 真机诊断子命令(直接调设备层和 WDA,不经守护进程),开发时用,默认不编进去:+# cargo build --features debug-cmds+debug-cmds = ["dep:ictl-wda"]diff --git a/apps/iphone-control/src/debug.rs b/apps/iphone-control/src/debug.rsindex 78503c0..12d6f33 100644--- a/apps/iphone-control/src/debug.rs+++ b/apps/iphone-control/src/debug.rs@@ -1,4 +1,4 @@-//! `iphone-control debug …`:真机诊断(原第 0 步 spike,结果见 docs/dev/spike-results.md)。直接调用设备层和 WDA 客户端,+//! `iphone-control debug …`:真机诊断(`--features debug-cmds` 才编译)。直接调用设备层和 WDA 客户端,//! 不经守护进程。`wda`、`e2e` 会启动 XCTest、`hid` 会开屏幕媒体流,和守护进程同时跑会互相干扰://! 先停掉守护进程(例如在另一个只跑 usbmuxd 的容器里运行)。@@ -7,10 +7,11 @@ use std::time::{Duration, Instant};use clap::{Args, Subcommand};use ictl_device::{Button, Device, ScreenSize};+use ictl_wda::client::SPRINGBOARD;#[derive(Args)]pub struct DebugArgs {- /// 屏幕点尺寸(HID 坐标换算用)+ /// 屏幕点尺寸(HID 坐标换算用;默认是 iPhone 15 Pro Max,别的机型按 `iphone-control status` 里的屏幕尺寸传)#[arg(long, default_value_t = 430.0)]width: f64,#[arg(long, default_value_t = 932.0)]@@ -53,7 +54,6 @@ enum Check {},}-const SPRINGBOARD: &str = "com.apple.springboard";const PREFERENCES: &str = "com.apple.Preferences";/// 等前台 App 变成 `want`,最多 8 秒;返回最后看到的前台 App@@ -115,7 +115,8 @@ async fn e2e_with_wda(let t = Instant::now();let els = wda.elements().await?;- let icon = els.iter().find(|e| e.label == "设置" && e.kind == "Icon").cloned();+ // 系统语言是中文或英文时主屏上「设置」的名字+ let icon = els.iter().find(|e| matches!(e.label.as_str(), "设置" | "Settings") && e.kind == "Icon").cloned();check("读元素",t,diff --git a/apps/iphone-control/src/main.rs b/apps/iphone-control/src/main.rsindex 95798fb..85c2cea 100644--- a/apps/iphone-control/src/main.rs+++ b/apps/iphone-control/src/main.rs@@ -9,8 +9,10 @@ use std::time::Duration;use anyhow::{Context, bail};use clap::{Parser, Subcommand};+use ictl_daemon::config::env as env_nonempty;use ictl_daemon::protocol::{self, Request, Response};+#[cfg(feature = "debug-cmds")]mod debug;#[derive(Parser)]@@ -61,7 +63,7 @@ enum Command {#[command(subcommand)]action: PasscodeAction,},- /// 自动解锁因输错被停用后,核对密码再恢复+ /// 解除自动解锁的停用(输错或中途出错后停用)。只删停用标记,不核对密码:先确认保存的密码对,必要时 passcode set 重设UnlockReset,/// 列出 USB 上接着的设备,标出正在控制哪台Devices,@@ -75,7 +77,8 @@ enum Command {#[arg(long, default_value_t = 8100)]port: u16,},- /// 真机诊断(原第 0 步 spike)。`wda`/`e2e`/`hid` 会和守护进程抢 XCTest、HID,先停掉守护进程+ /// 真机诊断(开发用,要用 `--features debug-cmds` 编译)。`wda`/`e2e`/`hid` 会和守护进程抢 XCTest、HID,先停掉守护进程+ #[cfg(feature = "debug-cmds")]#[command(hide = true)]Debug(debug::DebugArgs),/// 按已配置的渠道发测试通知:每类事件各一条(标题带「[测试]」),或只发指定的一类@@ -142,6 +145,7 @@ async fn main() -> anyhow::Result<()> {Command::Devices => print_text(&cli.socket, Request::ListDevices).await,Command::Select { device } => print_text(&cli.socket, Request::SelectDevice { device }).await,Command::WdaBridge { port } => wda_bridge(&cli.socket, port).await,+ #[cfg(feature = "debug-cmds")]Command::Debug(args) => debug::run(env_nonempty("IPHONE_UDID").as_deref(), args).await,Command::NotifyTest { event } => notify_test(&cli.data_dir, event.as_deref()).await,}@@ -210,11 +214,6 @@ fn shell_quote(s: &str) -> String {}}-/// 读环境变量,去掉首尾空白,空值当作没设(.env 里常留着 `KEY=`)-fn env_nonempty(key: &str) -> Option<String> {- std::env::var(key).ok().map(|v| v.trim().to_owned()).filter(|v| !v.is_empty())-}-async fn ask(socket: &Path, req: Request) -> anyhow::Result<Response> {// 签名要等装完,不设时限;其余命令守护进程忙也最多等 3 分钟let timeout = match req {@@ -438,9 +437,7 @@ async fn passcode(data_dir: &Path, socket: &Path, action: PasscodeAction) -> anyif p.len() < 4 || !p.bytes().all(|b| b.is_ascii_digit()) {bail!("只支持 4 位以上的纯数字密码");}- let dir = path.parent().context("密码文件路径没有上级目录")?;- std::fs::create_dir_all(dir)?;- std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o700))?;+ cfg.ensure_passcodes_dir()?;let mut f = std::fs::OpenOptions::new().create(true).write(true).truncate(true).mode(0o600).open(&path)?;// mode() 只在新建时生效:已有文件也收紧f.set_permissions(std::fs::Permissions::from_mode(0o600))?;diff --git a/crates/ictl-daemon/src/config.rs b/crates/ictl-daemon/src/config.rsindex 8e1c59c..2737b03 100644--- a/crates/ictl-daemon/src/config.rs+++ b/crates/ictl-daemon/src/config.rs@@ -9,8 +9,8 @@ use ictl_device::ScreenSize;pub struct Config {pub data_dir: PathBuf,pub socket: PathBuf,- /// 固定要控制的手机(`IPHONE_UDID`);None 时可以在运行中选(见 [`crate::core::Persisted::selected_udid`]),- /// 都没选就用第一台+ /// 固定要控制的手机(`IPHONE_UDID`);None 时可以在运行中选(见 [`crate::core::Persisted::selected_udid`])。+ /// 都没选是自动选:正在控制的那台一直用到断开,没有正在控制的才取 usbmuxd 列出的第一台pub udid: Option<String>,/// 由守护进程拉起并看护 usbmuxd。默认以 root 运行(容器)时为 true;普通用户拉起的 usbmuxd 碰不到 USB,/// 改用系统的 usbmuxd 服务。宿主机以 root 运行、又已有 usbmuxd 服务时设 ICTL_MANAGE_USBMUXD=0@@ -19,7 +19,7 @@ pub struct Config {/// 未签名的 WDA:镜像里自带;从源码运行时是数据目录里的 [`Config::wda_unsigned_cache`],第一次签名前下载pub wda_unsigned: PathBuf,pub ddi_url: String,- /// 自己从 Xcode 提取的 DDI Restore 目录;设了就不下载+ /// 自己从 Xcode 提取的 DDI Restore 目录;设了就不下载,也从不删除里面的文件pub ddi_dir: Option<PathBuf>,pub anisette_url: Option<String>,/// WDA 从没连上过时,HID 换算坐标用的屏幕尺寸@@ -46,7 +46,8 @@ impl NotifyConfig {}}-fn env(k: &str) -> Option<String> {+/// 读环境变量,去掉首尾空白,空值当作没设(.env 里常留着 `KEY=`)+pub fn env(k: &str) -> Option<String> {std::env::var(k).ok().map(|v| v.trim().to_owned()).filter(|v| !v.is_empty())}@@ -110,8 +111,9 @@ impl Config {pub fn wda_unsigned_is_cache(&self) -> bool {self.wda_unsigned == wda_unsigned_cache(&self.data_dir)}+ /// 守护进程自己下载的开发者镜像缓存(没设 `ICTL_DDI_DIR` 时用)pub fn ddi_cache(&self) -> PathBuf {- self.ddi_dir.clone().unwrap_or_else(|| self.data_dir.join("ddi"))+ self.data_dir.join("ddi")}/// 旧版本的锁屏密码:只有一份,不知道是哪台设备的。USB 上只接着一台时归到那台名下(见/// [`crate::core::Daemon::adopt_legacy_passcode`]),接着多台时不用,免得把一台的密码输进另一台@@ -121,6 +123,14 @@ impl Config {pub fn passcodes_dir(&self) -> PathBuf {self.data_dir.join("secrets/passcodes")}+ /// 建好 [`Self::passcodes_dir`],只有自己能进+ pub fn ensure_passcodes_dir(&self) -> std::io::Result<PathBuf> {+ use std::os::unix::fs::PermissionsExt;+ let dir = self.passcodes_dir();+ std::fs::create_dir_all(&dir)?;+ std::fs::set_permissions(&dir, std::fs::Permissions::from_mode(0o700))?;+ Ok(dir)+ }/// 这台设备的锁屏密码。UDID 来自 usbmuxd,只有字母、数字和 `-`;别的字符换掉,不让它变成路径pub fn passcode_file_for(&self, udid: &str) -> PathBuf {let name: String = udid.chars().map(|c| if c.is_ascii_alphanumeric() || c == '-' { c } else { '_' }).collect();diff --git a/crates/ictl-daemon/src/core.rs b/crates/ictl-daemon/src/core.rsindex 32a1ccc..f2addc9 100644--- a/crates/ictl-daemon/src/core.rs+++ b/crates/ictl-daemon/src/core.rs@@ -73,11 +73,16 @@ impl Persisted {/// 描述文件还剩多久;不知道返回 Nonepub fn profile_left(&self) -> Option<Duration> {- let now = SystemTime::now().duration_since(UNIX_EPOCH).ok()?.as_secs();- self.profile_expires.map(|e| Duration::from_secs(e.saturating_sub(now)))+ self.profile_expires.and_then(left_until)}}+/// 离 Unix 时间 `at`(秒)还有多久,过了是 0+fn left_until(at: u64) -> Option<Duration> {+ let now = SystemTime::now().duration_since(UNIX_EPOCH).ok()?.as_secs();+ Some(Duration::from_secs(at.saturating_sub(now)))+}+/// 这台手机上装着的 WDA 描述文件(经 misagent 读)。[`Persisted`] 只记最近一次签名:给别的手机签过之后,/// 它的到期时间不是这台手机上那份的(这台装的还是更早签的),按它判断会该重签时不重签#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]@@ -97,10 +102,7 @@ impl DeviceProfile {/// 还剩多久:读到了用手机上的;还没读、读不出来按签名记录;手机上没有返回 Nonepub fn left(&self, persisted: &Persisted) -> Option<Duration> {match self {- Self::Expires(e) => {- let now = SystemTime::now().duration_since(UNIX_EPOCH).ok()?.as_secs();- Some(Duration::from_secs(e.saturating_sub(now)))- }+ Self::Expires(e) => left_until(*e),Self::Missing => None,Self::NotChecked | Self::Unknown(_) => persisted.profile_left(),}@@ -123,6 +125,16 @@ pub fn wda_profile_expiry(profiles: &[Vec<u8>], team: Option<&str>, bundle: &str.max()}+/// 一次请求的附带条件(来自请求里的 [`ictl_protocol::CANCEL_ON_CLOSE`]、[`ictl_protocol::EXPECT_UDID`])+#[derive(Default)]+pub struct CallCtx {+ /// 调用方断开时收到信号。还在排队等设备锁的请求就不执行了;+ /// 已经开始执行的照常做完(中途打断会留下改了一半的 WDA 设置)+ pub gone: Option<tokio::sync::oneshot::Receiver<()>>,+ /// 正在控制的不是这台就不执行+ pub expect_udid: Option<String>,+}+/// 快照:`iphone-control status` 显示#[derive(Debug, Clone, Serialize, Deserialize)]pub struct Snapshot {@@ -233,7 +245,9 @@ pub(crate) fn wda_down(state: &DeviceState, info: Option<&DeviceInfo>) -> String} else {"这台手机 iOS 低于 27,没有 HID 后备路线,WDA 恢复前截图、点击等操作都用不了"};- format!("WDA 不可用({}),守护进程一般 1~2 分钟内会拉起;{fallback}", state.describe())+ // 状态还是「就绪」:WDA 在两次巡检之间刚掉线,下一轮巡检才会发现并重新拉起+ let why = if *state == DeviceState::Ready { "刚掉线".to_owned() } else { state.describe() };+ format!("WDA 不可用({why}),守护进程一般 1~2 分钟内会拉起;{fallback}")}/// HID 后备路线(免 WDA 截图、点击)只有 iOS 27 起能用;不知道版本时照常尝试@@ -335,12 +349,7 @@ impl Daemon {if dst.exists() {return;}- let r = std::fs::create_dir_all(self.cfg.passcodes_dir())- .and_then(|_| {- use std::os::unix::fs::PermissionsExt;- std::fs::set_permissions(self.cfg.passcodes_dir(), std::fs::Permissions::from_mode(0o700))- })- .and_then(|_| std::fs::rename(&legacy, &dst));+ let r = self.cfg.ensure_passcodes_dir().and_then(|_| std::fs::rename(&legacy, &dst));match r {Ok(()) => self.log.log(&format!("旧的锁屏密码只有一份,USB 上只接着 {},归到它名下", d.udid)),Err(e) => tracing::warn!("把旧的锁屏密码归到 {} 名下失败:{e}", d.udid),@@ -368,7 +377,6 @@ impl Daemon {}}- /// 丢掉整个会话:runner、WDA 客户端、正在后台启动的任务、隧道(先停 HID 媒体流)/// 重读这台手机上的 WDA 描述文件(misagent,一次约几十毫秒)pub(crate) async fn refresh_device_profile(&self, g: &mut Inner) {let Some(d) = g.device.clone() else {@@ -391,6 +399,7 @@ impl Daemon {};}+ /// 丢掉整个会话:runner、WDA 客户端、正在后台启动的任务、隧道(先停 HID 媒体流)pub(crate) async fn drop_session(&self, g: &mut Inner) {if let Some(h) = g.starting.take() {h.abort();@@ -451,7 +460,7 @@ impl Daemon {// ------------------------------------------------------------------ 请求处理/// 处理一个控制请求。`queued_at`:请求到达的时间,用来放弃排队太久的操作- pub async fn handle(self: &Arc<Self>, req: Request, queued_at: Instant) -> Response {+ pub async fn handle(self: &Arc<Self>, req: Request, queued_at: Instant, ctx: CallCtx) -> Response {// 不需要设备锁的请求match req {Request::Daemon => {@@ -472,8 +481,24 @@ impl Daemon {return Response::error(e);}- let mut g = self.inner.lock().await;+ let mut g = match ctx.gone {+ Some(mut gone) => tokio::select! {+ biased;+ g = self.inner.lock() => g,+ Ok(()) = &mut gone => return Response::error("调用方已取消,请求没有执行"),+ },+ None => self.inner.lock().await,+ };let g = &mut *g;+ if let Some(want) = &ctx.expect_udid {+ let now = g.device.as_ref().map(|d| d.udid.as_str());+ if now != Some(want.as_str()) {+ return Response::error(format!(+ "正在控制的设备变了(原来是 {want},现在{}),没有执行;先用 iphone_list_devices 确认",+ now.map_or("没有设备".into(), |u| format!("是 {u}"))+ ));+ }+ }if req.is_device_action() && queued_at.elapsed() > STALE {return Response::error(format!("守护进程正忙,这个操作排队超过 {} 秒,已放弃执行(以免落到已经变化的屏幕上);先截图看看再重试",@@ -563,6 +588,35 @@ fn check_request(req: &Request) -> Result<(), String> {mod tests {use super::*;+ fn test_daemon(tag: &str) -> (Arc<Daemon>, std::path::PathBuf) {+ let dir = std::env::temp_dir().join(format!("ictl-core-{tag}-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ (Daemon::new(Config::from_env(&dir)), dir)+ }++ /// 调用方已经断开:还在排队等设备锁的请求不执行+ #[tokio::test]+ async fn queued_request_is_dropped_when_caller_is_gone() {+ let (d, dir) = test_daemon("gone");+ let busy = d.inner.lock().await;+ let (tx, rx) = tokio::sync::oneshot::channel();+ tx.send(()).unwrap();+ let r = d.handle(Request::Status, Instant::now(), CallCtx { gone: Some(rx), expect_udid: None }).await;+ drop(busy);+ assert!(matches!(&r, Response::Error { message } if message.contains("已取消")), "{r:?}");+ std::fs::remove_dir_all(dir).unwrap();+ }++ /// 批量执行要求的设备不是正在控制的那台(例如拔线后改控了另一台):不执行+ #[tokio::test]+ async fn request_for_another_device_is_refused() {+ let (d, dir) = test_daemon("expect");+ let ctx = CallCtx { gone: None, expect_udid: Some("00008130-AAAA".into()) };+ let r = d.handle(Request::Status, Instant::now(), ctx).await;+ assert!(matches!(&r, Response::Error { message } if message.contains("设备变了")), "{r:?}");+ std::fs::remove_dir_all(dir).unwrap();+ }+/// 手机上的描述文件:CMS 外壳里包着 XML plist(同 ictl-sign 的解析方式)fn profile(app_id: &str, devices: &[&str], expires: &str) -> Vec<u8> {let devs: String = devices.iter().map(|d| format!("<string>{d}</string>")).collect();@@ -580,6 +634,7 @@ mod tests {#[test]fn wda_down_when_no_device_does_not_promise_recovery() {+ assert!(wda_down(&DeviceState::Ready, None).starts_with("WDA 不可用(刚掉线)"));let m = wda_down(&DeviceState::Absent, None);assert!(m.contains("手机未连接") && !m.contains("1~2 分钟") && !m.contains("可照常用"), "{m}");}diff --git a/crates/ictl-daemon/src/doctor.rs b/crates/ictl-daemon/src/doctor.rsindex 1dcbaa4..c1d130b 100644--- a/crates/ictl-daemon/src/doctor.rs+++ b/crates/ictl-daemon/src/doctor.rs@@ -27,10 +27,10 @@ impl Daemon {}}// 判断不了(不是 Linux/macOS)就不报,免得误报「没有设备」- match ictl_device::host_apple_usb_present().await {- Some(true) => out.push("✅ USB 上有 Apple 设备".into()),+ match ictl_device::host_ios_usb_present().await {+ Some(true) => out.push("✅ USB 上有 iPhone/iPad".into()),Some(false) => {- out.push("❌ USB 上没有 Apple 设备\n → 插好数据线;用 USB-C 转接头的话换一根试试".into());+ out.push("❌ USB 上没有 iPhone/iPad\n → 插好数据线;用 USB-C 转接头的话换一根试试".into());fails += 1;}None => {}diff --git a/crates/ictl-daemon/src/lib.rs b/crates/ictl-daemon/src/lib.rsindex 3b872dd..a513750 100644--- a/crates/ictl-daemon/src/lib.rs+++ b/crates/ictl-daemon/src/lib.rs@@ -111,8 +111,29 @@ async fn serve_conn(daemon: Arc<Daemon>, stream: tokio::net::UnixStream) {let resp = if line.len() as u64 > MAX_REQUEST_LINE {protocol::Response::error("请求太长")} else {- match serde_json::from_slice::<protocol::Request>(&line) {- Ok(req) => daemon.handle(req, queued_at).await,+ match parse_request(&line) {+ Ok((req, false, expect_udid)) => {+ daemon.handle(req, queued_at, core::CallCtx { gone: None, expect_udid }).await+ }+ Ok((req, true, expect_udid)) => {+ // 调用方断开(取消、超时)就告诉 handle:还在排队的话不再执行+ let (gone_tx, gone_rx) = tokio::sync::oneshot::channel();+ let mut gone_tx = Some(gone_tx);+ let handling = daemon.handle(req, queued_at, core::CallCtx { gone: Some(gone_rx), expect_udid });+ tokio::pin!(handling);+ let resp = loop {+ tokio::select! {+ r = &mut handling => break r,+ () = wait_closed(&mut reader), if gone_tx.is_some() => {+ let _ = gone_tx.take().map(|t| t.send(()));+ }+ }+ };+ if gone_tx.is_none() {+ break;+ }+ resp+ }Err(e) => protocol::Response::error(format!("请求格式错误:{e}")),}};@@ -123,3 +144,42 @@ async fn serve_conn(daemon: Arc<Daemon>, stream: tokio::net::UnixStream) {}}}++/// 解析一行请求,并取出 [`protocol::CANCEL_ON_CLOSE`]、[`protocol::EXPECT_UDID`]+fn parse_request(line: &[u8]) -> serde_json::Result<(protocol::Request, bool, Option<String>)> {+ let mut v: serde_json::Value = serde_json::from_slice(line)?;+ let (cancel, expect) = match v.as_object_mut() {+ Some(o) => (+ o.remove(protocol::CANCEL_ON_CLOSE).is_some_and(|c| c == true),+ o.remove(protocol::EXPECT_UDID).and_then(|u| u.as_str().map(str::to_owned)),+ ),+ None => (false, None),+ };+ Ok((serde_json::from_value(v)?, cancel, expect))+}++/// 等到调用方关掉连接(读到 EOF 或出错)。带 cancel_on_close 的客户端一个连接只发一个请求,之后不会再写+async fn wait_closed<R: tokio::io::AsyncRead + Unpin>(reader: &mut R) {+ let mut buf = [0u8; 64];+ while let Ok(n) = reader.read(&mut buf).await+ && n > 0+ {}+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn request_options_are_taken_out_before_parsing() {+ let (req, cancel, expect) =+ parse_request(br#"{"op":"tap","x":1.0,"y":2.0,"cancel_on_close":true,"expect_udid":"U1"}"#).unwrap();+ assert_eq!(req, protocol::Request::Tap { x: 1.0, y: 2.0 });+ assert!(cancel);+ assert_eq!(expect.as_deref(), Some("U1"));+ // 旧版本客户端:没有这两个键+ let (_, cancel, expect) = parse_request(br#"{"op":"status"}"#).unwrap();+ assert!(!cancel && expect.is_none());+ assert!(parse_request(b"{").is_err());+ }+}diff --git a/crates/ictl-daemon/src/machine.rs b/crates/ictl-daemon/src/machine.rsindex 40b61a2..2587585 100644--- a/crates/ictl-daemon/src/machine.rs+++ b/crates/ictl-daemon/src/machine.rs@@ -50,6 +50,8 @@ pub struct Backoff {pub const BACKOFF_START: Duration = Duration::from_secs(60);pub const BACKOFF_MAX: Duration = Duration::from_secs(300);pub const PIN_RETRY: Duration = Duration::from_secs(60);+/// 手机锁着、建不了隧道时多久再试(不用等 60 秒那么久:用户解锁后很快就能起来)+pub const UNLOCK_RETRY: Duration = Duration::from_secs(20);impl Default for Backoff {fn default() -> Self {@@ -68,7 +70,12 @@ impl Backoff {}pub fn waiting_for_pin(&mut self, now: Instant) {- self.next_at = Some(now + PIN_RETRY);+ self.retry_after(now, PIN_RETRY);+ }++ /// 等用户在手机上操作(输密码、解锁):固定间隔重试,不翻倍,用户弄好后很快就能起来+ pub fn retry_after(&mut self, now: Instant, d: Duration) {+ self.next_at = Some(now + d);self.delay = BACKOFF_START;}@@ -157,6 +164,19 @@ mod tests {assert!(b.ready(t));}+ /// 手机锁着、建不了隧道:固定间隔再试,不翻倍(用户解锁后很快就能起来)+ #[test]+ fn unlock_wait_retries_at_fixed_interval() {+ let t = Instant::now();+ let mut b = Backoff::default();+ for _ in 0..3 {+ b.retry_after(t, UNLOCK_RETRY);+ assert!(!b.ready(t + UNLOCK_RETRY - Duration::from_secs(1)));+ assert!(b.ready(t + UNLOCK_RETRY));+ }+ assert_eq!(b.current_delay(), BACKOFF_START);+ }+/// 回归用例 #8:等自动化密码时固定 60 秒重试,不指数退避#[test]fn pin_wait_retries_every_minute() {diff --git a/crates/ictl-daemon/src/supervise.rs b/crates/ictl-daemon/src/supervise.rsindex c5e3a97..7b59331 100644--- a/crates/ictl-daemon/src/supervise.rs+++ b/crates/ictl-daemon/src/supervise.rs@@ -24,12 +24,27 @@ const USBMUXD_MAX_DELAY: Duration = Duration::from_secs(300);const LIST_ERRORS_OFFLINE: u32 = 3;/// 开发者镜像连续挂载失败这么多次就清缓存重新下载const DDI_FAILURES_INVALIDATE: u32 = 3;+/// 整个重签(登录会话、注册设备、签名、上传安装)的时限:苹果服务器或安装卡住时不能永远「正在重签」+const RESIGN_TIMEOUT: Duration = Duration::from_secs(15 * 60);+/// Apple ID 会话检查的时限+const SESSION_CHECK_TIMEOUT: Duration = Duration::from_secs(3 * 60);+/// 换了设备或重新接上后,这么久内就检查一次要不要重签(离线期间可能过期了,不能等满 RESIGN_CHECK_HOURS)+const RESIGN_CHECK_AFTER_CONNECT: Duration = Duration::from_secs(60);/// 后台启动 WDA 的结果pub(crate) enum StartOutcome {- Ready { runner: WdaRunner, client: WdaClient<DeviceTransport>, mounted: Option<String> },+ Ready {+ runner: WdaRunner,+ client: WdaClient<DeviceTransport>,+ mounted: Option<String>,+ },NeedsUnlock,- Ddi(String),+ /// 开发者镜像没准备好。`mount_failed`:是挂载这一步失败(才可能是缓存坏了);+ /// 建隧道、查询、下载失败都是 false+ Ddi {+ error: String,+ mount_failed: bool,+ },Wda(WdaError),}@@ -212,6 +227,7 @@ impl Daemon {self.log.log(&format!("手机在线{model}"));g.device = Some(d);g.backoff.reset();+ g.next_resign = g.next_resign.min(Instant::now() + RESIGN_CHECK_AFTER_CONNECT);if let Some(since) = g.offline_since.take()&& g.dedup.was_sent("offline"){@@ -246,12 +262,7 @@ impl Daemon {};if ready {g.wda_misses.reset();- // 记下界面往哪边转:WDA 挂了以后 HID 点击要靠它换算横屏坐标(约 20 毫秒)- if let Some(w) = g.wda.as_mut()- && let Ok(r) = w.rotation().await- {- g.wda_rotation = Some((Instant::now(), r));- }+ self.refresh_hid_rotation(g).await;if g.state != DeviceState::Ready {if g.state == DeviceState::NeedsAutomationPin || g.dedup.was_sent("pin") {g.dedup.clear("pin");@@ -289,22 +300,26 @@ impl Daemon {/// 在后台启动 WDA:挂开发者镜像(单独开一条隧道,用完关掉)→ 启动 runner 等就绪。/// 最长约 2 分钟(等「Enable UI Automation」密码时),期间不持锁:工具调用照常走 HID 后备路线fn spawn_start(&self, g: &mut Inner, device: Device, bundle: String) {- // 正在等密码时保持这个状态,免得每次重试都在两个状态间来回切、刷日志- if g.state != DeviceState::NeedsAutomationPin {+ // 正在等密码、等解锁时保持这个状态,免得每次重试都在两个状态间来回切、刷日志+ if !matches!(g.state, DeviceState::NeedsAutomationPin | DeviceState::NeedsUnlock) {self.set_state(g, DeviceState::WdaStarting { last_error: None });}self.log.log("启动 WDA");- let (cache, url) = (self.cfg.ddi_cache(), self.cfg.ddi_url.clone());+ let (cache, url, user_dir) = (self.cfg.ddi_cache(), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone());g.starting = Some(tokio::task::spawn_local(async move {- // 手机重启后开发者镜像可能掉了;已挂载时只是一次查询- let ddi: Result<Option<String>, DeviceError> = async {- let mut t = device.open_tunnel().await?;+ // 手机重启后开发者镜像可能掉了;已挂载时只是一次查询。错误带上「是不是挂载这一步」+ let ddi: Result<Option<String>, (DeviceError, bool)> = async {+ let mut t = device.open_tunnel().await.map_err(|e| (e, false))?;let r = async {- if t.ddi_mounted().await?.is_some() {+ if t.ddi_mounted().await.map_err(|e| (e, false))?.is_some() {return Ok(None);}- let dir = ictl_device::ddi::ensure_cache(&cache, &url).await?;- Ok(Some(t.mount_ddi(&dir).await?))+ let dir = match &user_dir {+ Some(d) => ictl_device::ddi::require_complete(d),+ None => ictl_device::ddi::ensure_cache(&cache, &url).await,+ }+ .map_err(|e| (e, false))?;+ Ok(Some(t.mount_ddi(&dir).await.map_err(|e| (e, true))?))}.await;t.close().await;@@ -313,8 +328,8 @@ impl Daemon {.await;let mounted = match ddi {Ok(v) => v,- Err(DeviceError::PasswordProtected) => return StartOutcome::NeedsUnlock,- Err(e) => return StartOutcome::Ddi(e.to_string()),+ Err((DeviceError::PasswordProtected, _)) => return StartOutcome::NeedsUnlock,+ Err((e, mount_failed)) => return StartOutcome::Ddi { error: e.to_string(), mount_failed },};match WdaRunner::start(device.provider(), &bundle, WDA_START_TIMEOUT).await {Ok((runner, client)) => StartOutcome::Ready { runner, client, mounted },@@ -341,13 +356,20 @@ impl Daemon {g.wda = Some(client);// 状态在下面 online() 的健康检查里变成 Ready}- StartOutcome::NeedsUnlock => self.set_state(g, DeviceState::NeedsUnlock),- StartOutcome::Ddi(e) => {- g.ddi_failures += 1;- if g.ddi_failures >= DDI_FAILURES_INVALIDATE {- self.log.log(&format!("开发者镜像连续 {} 次挂载失败,清掉缓存,下次重新下载", g.ddi_failures));- ictl_device::ddi::invalidate(&self.cfg.ddi_cache());- g.ddi_failures = 0;+ StartOutcome::NeedsUnlock => {+ // 不退避的话,紧接着的 online() 会立刻重新启动,状态被改回「正在启动」,用户看不到要解锁+ g.backoff.retry_after(Instant::now(), crate::machine::UNLOCK_RETRY);+ self.set_state(g, DeviceState::NeedsUnlock);+ }+ StartOutcome::Ddi { error: e, mount_failed } => {+ // 只有挂载失败才可能是缓存坏了;ICTL_DDI_DIR 是用户自己的文件,从不删+ if mount_failed && self.cfg.ddi_dir.is_none() {+ g.ddi_failures += 1;+ if g.ddi_failures >= DDI_FAILURES_INVALIDATE {+ self.log.log(&format!("开发者镜像连续 {} 次挂载失败,清掉缓存,下次重新下载", g.ddi_failures));+ ictl_device::ddi::invalidate(&self.cfg.ddi_cache());+ g.ddi_failures = 0;+ }}g.backoff.failed(Instant::now());self.set_state(g, DeviceState::WdaStarting { last_error: Some(format!("开发者镜像:{e}")) });@@ -372,10 +394,11 @@ impl Daemon {// plume_core 的 future 不是 Send,放到阻塞线程里 block_on(同重签);也不持锁let r: Result<(), Option<String>> = tokio::task::spawn_blocking(move || {tokio::runtime::Handle::current().block_on(async move {- match account.session().await {- Ok(_) => Ok(()),- Err(ictl_sign::SignError::NotLoggedIn) => Err(None),- Err(e) => Err(Some(e.to_string())),+ match tokio::time::timeout(SESSION_CHECK_TIMEOUT, account.session()).await {+ Ok(Ok(_)) => Ok(()),+ Ok(Err(ictl_sign::SignError::NotLoggedIn)) => Err(None),+ Ok(Err(e)) => Err(Some(e.to_string())),+ Err(_) => Err(Some(format!("{} 分钟内没有完成", SESSION_CHECK_TIMEOUT.as_secs() / 60))),}})})@@ -426,6 +449,7 @@ impl Daemon {self.log.log("开始重签");(device, name)};+ let signed_udid = device.udid.clone();let account = self.account();let (wda_dir, unsigned, signed_path) =(self.cfg.wda_dir(), self.cfg.wda_unsigned.clone(), self.cfg.wda_signed());@@ -435,19 +459,23 @@ impl Daemon {}// plume_core 的签名 future 不是 Send(持有 &mut dyn FnMut 和非 Send 的私钥),放到阻塞线程里 block_onlet r: Result<ictl_sign::Signed, String> = tokio::task::spawn_blocking(move || {- tokio::runtime::Handle::current().block_on(async move {- if fetch {- crate::wda_pkg::ensure(&unsigned).await?;- }- let session = account.session().await.map_err(|e| e.to_string())?;- session.ensure_device(&device.udid, &name).await.map_err(|e| e.to_string())?;- std::fs::create_dir_all(&wda_dir).map_err(|e| e.to_string())?;- let tmp = wda_dir.join("WDA-signing.ipa");- let signed = session.sign_ipa(&unsigned, &tmp, &device.udid).await.map_err(|e| e.to_string())?;- device.install(&tmp).await.map_err(|e| format!("安装到手机失败(手机锁屏?):{e}"))?;- std::fs::rename(&tmp, &signed_path).map_err(|e| e.to_string())?;- Ok(signed)- })+ tokio::runtime::Handle::current()+ .block_on(tokio::time::timeout(RESIGN_TIMEOUT, async move {+ if fetch {+ crate::wda_pkg::ensure(&unsigned).await?;+ }+ let session = account.session().await.map_err(|e| e.to_string())?;+ session.ensure_device(&device.udid, &name).await.map_err(|e| e.to_string())?;+ std::fs::create_dir_all(&wda_dir).map_err(|e| e.to_string())?;+ let tmp = wda_dir.join("WDA-signing.ipa");+ let signed = session.sign_ipa(&unsigned, &tmp, &device.udid).await.map_err(|e| e.to_string())?;+ device.install(&tmp).await.map_err(|e| format!("安装到手机失败(手机锁屏?):{e}"))?;+ std::fs::rename(&tmp, &signed_path).map_err(|e| e.to_string())?;+ Ok(signed)+ }))+ .unwrap_or_else(|_| {+ Err(format!("{} 分钟内没有完成(苹果服务器或安装卡住)", RESIGN_TIMEOUT.as_secs() / 60))+ })}).await.unwrap_or_else(|e| Err(format!("签名任务异常退出:{e}")));@@ -463,10 +491,12 @@ impl Daemon {g.persisted.profile_expires = Some(exp);g.persisted.last_resign = Some(format!("{} 成功", crate::eventlog::timestamp()));g.persisted.save(&self.cfg.state_file());- // 新包装上后旧的 runner 会失效,下一轮巡检重新拉起- self.drop_session(g).await;- self.refresh_device_profile(g).await;- g.backoff.reset();+ // 新包装上后旧的 runner 会失效,下一轮巡检重新拉起。签名期间切到了别的设备就不动它的会话+ if g.device.as_ref().is_some_and(|d| d.udid == signed_udid) {+ self.drop_session(g).await;+ self.refresh_device_profile(g).await;+ g.backoff.reset();+ }g.dedup.clear("resign");let msg = format!("重签完成,新描述文件到期 {} UTC", crate::eventlog::format_utc(exp));self.log.log(&msg);diff --git a/crates/ictl-daemon/src/tools.rs b/crates/ictl-daemon/src/tools.rsindex 8bb9931..35e417f 100644--- a/crates/ictl-daemon/src/tools.rs+++ b/crates/ictl-daemon/src/tools.rs@@ -5,6 +5,7 @@ use std::time::{Duration, Instant};use base64::Engine;use ictl_device::{AppInfo, Button, DeviceError, HidSession, Rotation, ScreenSize, apps, hid::ascii_to_usage};use ictl_unlock::UnlockError;+use ictl_wda::client::SPRINGBOARD;use ictl_wda::elements::{self, TapPoint, Tree};use ictl_wda::http::DeviceTransport;use ictl_wda::{Launch, WdaClient, WdaError};@@ -12,7 +13,7 @@ use ictl_wda::{Launch, WdaClient, WdaError};use crate::core::{Daemon, Inner, drop_tunnel, hid_supported, wda_down};use crate::imaging::{self, fmt_g};use crate::notify::Event;-use crate::protocol::Response;+use crate::protocol::{ALERT_BLOCKING, Response, TAP_MISSED};/// 锁屏后至少等这么久再自动解锁:锁屏过渡没走完就唤醒,WDA 第一下上滑卡约 16 秒后报 `point.x != INFINITY`pub(crate) const LOCK_SETTLE: Duration = Duration::from_secs(3);@@ -27,11 +28,12 @@ const LOCAL_MOTION: f64 = 4.0;const STILL_TOLERANCE: i64 = 3;/// 滑动后最多等这么久让列表停下(快速滑动的惯性滚动约 2 秒)const SCROLL_SETTLE: Duration = Duration::from_millis(2500);+/// WDA 不可用时 status 里说明哪些功能用不了+const NEEDS_WDA: &str = "读界面元素、按名字点击、启动 App、输入中文要等 WDA 恢复";/// 按 Home 后最多等这么久,确认主屏到了前台(iPhone 12 mini 上 IOHID 的 Home 约 1.3~1.5 秒)const HOME_SETTLE: Duration = Duration::from_secs(2);/// 按电源键后最多等这么久,等 WDA 报锁屏(iPhone 12 mini 实测约 1 秒)const LOCK_WAIT: Duration = Duration::from_secs(3);-const SPRINGBOARD: &str = "com.apple.springboard";impl Daemon {/// 配置了密码就在锁屏时自动解锁;没配置而手机锁着则报错(与 toolkit 一致)@@ -75,7 +77,8 @@ impl Daemon {.ok_or_else(|| "WDA 不可用,也不知道屏幕尺寸;等 WDA 起来一次,或在 .env 里设 SCREEN_W/SCREEN_H".into())}- async fn refresh_hid_rotation(&self, g: &mut Inner) {+ /// 记下 WDA 报的界面旋转角:WDA 挂了以后 HID 点击要靠它换算横屏坐标(约 20 毫秒)+ pub(crate) async fn refresh_hid_rotation(&self, g: &mut Inner) {if let Some(w) = self.wda(g)&& let Ok(r) = w.rotation().await{@@ -87,22 +90,25 @@ impl Daemon {/// 截图只给宽高,不能分辨横屏左右;短暂掉线时借用近期 WDA 方向,过期或不匹配就不触摸。async fn hid_touch_rotation(&self, g: &mut Inner) -> Result<Rotation, String> {self.refresh_hid_rotation(g).await;- let device = g.device.clone().ok_or("手机未连接")?;- let png = {- let t = self.ensure_tunnel(g, &device).await.map_err(|e| format!("核对 HID 方向失败:{e}"))?;- match t.screenshot_png().await {- Ok(p) => p,- Err(e) => {- drop_tunnel(g).await;- return Err(format!("核对 HID 方向失败,没有发送触摸:{e}"));- }- }- };+ let png = self.hid_screenshot(g).await.map_err(|e| format!("核对 HID 方向失败,没有发送触摸:{e}"))?;let (w, h) = imaging::png_size(&png).ok_or("无法读取截图尺寸,没有发送触摸")?;let known = g.wda_rotation.map(|(at, r)| (at.elapsed(), r));hid_rotation(w, h, known)}+ /// 经隧道截图(WDA 不可用时)。失败就丢掉隧道,下次重建+ async fn hid_screenshot(&self, g: &mut Inner) -> Result<Vec<u8>, String> {+ let device = g.device.clone().ok_or("手机未连接")?;+ let t = self.ensure_tunnel(g, &device).await.map_err(|e| e.to_string())?;+ match t.screenshot_png().await {+ Ok(p) => Ok(p),+ Err(e) => {+ drop_tunnel(g).await;+ Err(e.to_string())+ }+ }+ }+/// HID 会话(WDA 不可用时的后备路线)。开不起来就丢掉隧道,下次重建async fn hid<'a>(&self, g: &'a mut Inner) -> Result<&'a mut HidSession, String> {// 低版本建隧道只会报 service not found:直接说清楚@@ -178,17 +184,17 @@ impl Daemon {}let unlock = self.unlock_cfg(g.device.as_ref().map(|d| d.udid.as_str()));let Some(w) = self.wda(g) else {- return format!(- "{}\n读界面元素、按名字点击、启动 App、输入中文要等 WDA 恢复\n{daemon_line}",- wda_down(&g.state, g.info.as_ref())- );+ return format!("{}\n{NEEDS_WDA}\n{daemon_line}", wda_down(&g.state, g.info.as_ref()));};let r: Result<String, WdaError> = async {let ready = w.ready().await?;let app = w.active_app().await?;let s = w.screen_size().await?;- let locked = w.locked().await?;- let mut lock = if !locked {+ let check = w.check_lock(None, false).await?;+ let locked = check.locked;+ let mut lock = if check.uncertain {+ "可能已锁屏(屏幕上是锁屏样式的界面,WDA 说没锁;配置了自动解锁时操作前会先尝试解锁)".to_owned()+ } else if !locked {"未锁屏".to_owned()} else if unlock.disabled_by_failure() {"已锁屏(自动解锁之前失败过已停用,需要人工解锁,核对密码后运行 iphone-control unlock-reset)".to_owned()@@ -210,7 +216,7 @@ impl Daemon {.await;match r {Ok(t) => format!("{t}\n{daemon_line}"),- Err(e) => format!("{e}\n读界面元素、按名字点击、启动 App、输入中文要等 WDA 恢复\n{daemon_line}"),+ Err(e) => format!("{e}\n{NEEDS_WDA}\n{daemon_line}"),}}@@ -234,15 +240,7 @@ impl Daemon {if !hid_supported(g.info.as_ref()) {return Err(wda_down(&g.state, g.info.as_ref()));}- let device = g.device.clone().ok_or("手机未连接")?;- let t = self.ensure_tunnel(g, &device).await.map_err(|e| format!("HID 命令失败: {e}"))?;- match t.screenshot_png().await {- Ok(p) => (p, "HID"),- Err(e) => {- drop_tunnel(g).await;- return Err(format!("HID 命令失败: {e}"));- }- }+ (self.hid_screenshot(g).await.map_err(|e| format!("HID 命令失败: {e}"))?, "HID")}};let screen = self.screen(g).await?;@@ -331,9 +329,7 @@ impl Daemon {let mut prev: Option<Vec<u8>> = None;loop {let png = w.screenshot_png().await.map_err(|e| e.to_string())?;- let cur = tokio::task::spawn_blocking(move || imaging::thumbnail(&png))- .await- .map_err(|e| format!("图像处理任务异常:{e}"))??;+ let cur = thumbnail(png).await?;if let Some(p) = &prev {let m = imaging::thumb_motion(p, &cur);if m.mean < VISUAL_STILL {@@ -363,10 +359,8 @@ impl Daemon {tokio::time::sleep(Duration::from_millis(150)).await;}let Ok(png) = w.screenshot_png().await else { return String::new() };- match tokio::task::spawn_blocking(move || imaging::thumbnail(&png)).await {- Ok(Ok(t)) => thumbs.push(t),- _ => return String::new(),- }+ let Ok(t) = thumbnail(png).await else { return String::new() };+ thumbs.push(t);}let m = imaging::thumb_motion(&thumbs[0], &thumbs[1]);if (m.mean >= VISUAL_STILL || m.max_tile >= LOCAL_MOTION) && imaging::mostly_blank(&thumbs[1]) {@@ -448,11 +442,11 @@ impl Daemon {let tree = self.tree(g, max_age).await?;let matches = elements::find(&tree.elements, text);if matches.is_empty() {- return Ok(format!("没找到包含 \"{text}\" 的元素,先用 iphone_list_elements 或截图看看屏幕"));+ return Ok(format!("{}包含 \"{text}\" 的元素,先用 iphone_list_elements 或截图看看屏幕", TAP_MISSED[0]));}if index >= matches.len() {let list: Vec<_> = matches.iter().map(|e| e.describe()).collect();- return Ok(format!("只匹配到 {} 个:\n{}", matches.len(), list.join("\n")));+ return Ok(format!("{} {} 个:\n{}", TAP_MISSED[1], matches.len(), list.join("\n")));}let e = matches[index];// 中心被悬浮栏、键盘、浮层之类盖住时,点上去会落在盖着的东西上@@ -463,7 +457,8 @@ impl Daemon {}TapPoint::Covered { by } => {return Ok(format!(- "被挡住:{} 整个被「{by}」盖住,没有点;先滑动让它露出来,或截图后按坐标点",+ "{}:{} 整个被「{by}」盖住,没有点;先滑动让它露出来,或截图后按坐标点",+ TAP_MISSED[2],e.describe()));}@@ -577,9 +572,7 @@ impl Daemon {if hid_button == Button::Home&& let Ok(Some(text)) = w.alert_text().await{- return Ok(format!(- "屏幕上有系统弹窗「{text}」挡着,按 Home 不会生效,没有按;先用 iphone_tap_element 点弹窗上的按钮"- ));+ return Ok(format!("{},按 Home 不会生效,没有按;{TAP_ALERT}", blocking(&text)));}let r = if hid_button == Button::Home {press_home(w).await@@ -660,7 +653,7 @@ impl Daemon {Ok(match w.launch_app(&bid).await.map_err(|e| e.to_string())? {Launch::Foreground => format!("已启动 {bid}"),Launch::Blocked(text) => {- format!("已启动 {bid},但屏幕上有系统弹窗「{text}」挡着;先用 iphone_tap_element 点弹窗上的按钮")+ format!("已启动 {bid},但{};{TAP_ALERT}", blocking(&text))}Launch::Slow => format!("已启动 {bid},但 8 秒内没到前台(可能启动慢),先截图确认"),})@@ -679,7 +672,7 @@ impl Daemon {Ok(match r {Launch::Foreground => format!("已打开 {url}(前台 {app})"),Launch::Blocked(text) => {- format!("已打开 {url},但屏幕上有系统弹窗「{text}」挡着;先用 iphone_tap_element 点弹窗上的按钮")+ format!("已打开 {url},但{};{TAP_ALERT}", blocking(&text))}Launch::Slow => format!("已打开 {url},但 8 秒内没有 App 到前台(前台还是 {app}),先截图确认"),})@@ -704,7 +697,6 @@ pub(crate) fn hid_rotation(w: u32, h: u32, known: Option<(Duration, Rotation)>)Ok(if recent == Some(Rotation::UpsideDown) { Rotation::UpsideDown } else { Rotation::Portrait })}-/// 屏幕中间(上下各去掉一段,留给导航栏、标签栏)几乎没有元素:加载中、空白页/// 按 Home,等主屏真的到前台再说「已按」(紧接着查状态时前台不再是旧 App)。/// 先经 IOHID 按(XCTest 的 home 在 iPhone 12 mini / iOS 26.4.1 上不起作用却报成功),/// [`HOME_SETTLE`] 内没回到主屏再用 XCTest 的 home 补一次;IOHID 这一下报错也改用 XCTest 的@@ -759,6 +751,7 @@ async fn lock_by_power_hid(w: &mut WdaClient<DeviceTransport>) -> bool {}}+/// 屏幕中间(上下各去掉一段,留给导航栏、标签栏)几乎没有元素:加载中、空白页fn middle_is_empty(tree: &Tree, screen_h: f64) -> bool {let (top, bottom) = ((screen_h * 0.25) as i64, (screen_h * 0.85) as i64);tree.elements.iter().filter(|e| e.center.1 > top && e.center.1 < bottom).count() <= 1@@ -830,6 +823,11 @@ async fn poll_stable(Ok((first, Some((msg, prev))))}+/// 判断画面动没动用的缩略图。解码是 CPU 活,放到阻塞线程+async fn thumbnail(png: Vec<u8>) -> Result<Vec<u8>, String> {+ tokio::task::spawn_blocking(move || imaging::thumbnail(&png)).await.map_err(|e| format!("图像处理任务异常:{e}"))?+}+/// 列元素一个都没列出来时的说明。带 filter 没匹配上时要说清楚,不然 agent 会以为屏幕上什么都没有fn no_elements_text(filter: &str, total: usize) -> String {if filter.is_empty() || total == 0 {@@ -841,7 +839,14 @@ fn no_elements_text(filter: &str, total: usize) -> String {}fn alert_msg(text: &str) -> String {- format!("\n注意:屏幕上有系统弹窗「{text}」挡着,点击、滑动都会落在弹窗上;先用 iphone_tap_element 点弹窗上的按钮")+ format!("\n注意:{},点击、滑动都会落在弹窗上;{TAP_ALERT}", blocking(text))+}++const TAP_ALERT: &str = "先用 iphone_tap_element 点弹窗上的按钮";++/// 「屏幕上有系统弹窗「…」挡着」:MCP 端靠固定的开头认出结果里已经报过弹窗+fn blocking(text: &str) -> String {+ format!("{ALERT_BLOCKING}「{text}」挡着")}/// 树里有弹窗就返回提醒diff --git a/crates/ictl-device/src/apps.rs b/crates/ictl-device/src/apps.rsindex 0401205..c26bd51 100644--- a/crates/ictl-device/src/apps.rs+++ b/crates/ictl-device/src/apps.rs@@ -2,7 +2,7 @@use std::collections::HashMap;-#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]+#[derive(Debug, Clone, PartialEq, Eq)]pub struct AppInfo {pub name: String,pub bundle_id: String,diff --git a/crates/ictl-device/src/ddi.rs b/crates/ictl-device/src/ddi.rsindex 02a31cb..7e615a9 100644--- a/crates/ictl-device/src/ddi.rs+++ b/crates/ictl-device/src/ddi.rs@@ -23,7 +23,19 @@ pub fn cache_complete(dir: &Path) -> bool {FILES.iter().all(|f| dir.join(f).is_file())}-/// 删掉缓存(挂载反复失败时调用,下次重新下载)+/// 用户自己提供的目录(`ICTL_DDI_DIR`):不下载、不改动,只检查文件齐不齐+pub fn require_complete(dir: &Path) -> Result<PathBuf> {+ let missing: Vec<&str> = FILES.iter().copied().filter(|f| !dir.join(f).is_file()).collect();+ if missing.is_empty() {+ return Ok(dir.to_owned());+ }+ Err(DeviceError::Io(std::io::Error::new(+ std::io::ErrorKind::NotFound,+ format!("ICTL_DDI_DIR({})里缺少 {}", dir.display(), missing.join("、")),+ )))+}++/// 删掉缓存(挂载反复失败时调用,下次重新下载)。只用于守护进程自己下载的缓存目录pub fn invalidate(dir: &Path) {for f in FILES.iter().chain([&SOURCE_STAMP]) {let _ = std::fs::remove_file(dir.join(f));@@ -86,8 +98,11 @@ mod tests {assert!(!cache_complete(&dir));std::fs::write(dir.join(FILES[4]), b"x").unwrap();assert!(cache_complete(&dir));+ assert!(require_complete(&dir).is_ok());invalidate(&dir);assert!(!cache_complete(&dir));+ let e = require_complete(&dir).unwrap_err().to_string();+ assert!(e.contains("BuildManifest.plist") && e.contains("Image.dmg.root_hash"), "{e}");std::fs::remove_dir_all(&dir).unwrap();}}diff --git a/crates/ictl-device/src/hid.rs b/crates/ictl-device/src/hid.rsindex 757ecdd..415ba81 100644--- a/crates/ictl-device/src/hid.rs+++ b/crates/ictl-device/src/hid.rs@@ -119,13 +119,14 @@ impl HidSession {screen: ScreenSize,) -> Result<Self> {let stream = crate::media::start(adapter, handshake, 1).await?;- let clients = async {+ // 时限加在这里而不是外层:外层取消会直接丢掉媒体流,走不到下面的 stop+ let clients = limit("连接 HID 服务", Duration::from_secs(20), async {// backboardd 要一点时间把 HID 设备和刚授权的媒体流对上tokio::time::sleep(Duration::from_millis(300)).await;let touch = UniversalHidServiceClient::connect_rsd(adapter, handshake).await?;let indigo = IndigoHidClient::connect_rsd(adapter, handshake).await?;Ok::<_, DeviceError>((touch, indigo))- }+ }).await;match clients {Ok((touch, indigo)) => Ok(Self {diff --git a/crates/ictl-device/src/lib.rs b/crates/ictl-device/src/lib.rsindex 61e24fb..a4d7279 100644--- a/crates/ictl-device/src/lib.rs+++ b/crates/ictl-device/src/lib.rs@@ -1,6 +1,6 @@//! 设备层:一台 iPhone 的全部底层能力,基于 `idevice`。//!-//! - 发现:usbmuxd `get_devices`;容器里没有 udev,另用 sysfs 判断 USB 上是否有 Apple 设备([`apple_usb_present`])+//! - 发现:usbmuxd `get_devices`;容器里没有 udev,另用 sysfs 数 USB 上有几台 iPhone/iPad([`ios_usb_count`])//! - 配对、设备信息、开发者模式:lockdown / amfi//! - 隧道:CoreDeviceProxy + jktcp 用户态 TCP 栈(免 root、不建网卡),RSD 握手([`Tunnel`])//! - 开发者镜像:`cryptexd::installed_ddi` / `install_ddi`(个性化 + TSS);DDI 下载见 [`ddi`]@@ -70,6 +70,9 @@ pub enum DeviceError {InvalidInput(String),}+/// usbmuxd、lockdown 这类一问一答的查询的时限。idevice 读应答没有超时,对方接了连接不应答会一直等+const QUERY: Duration = Duration::from_secs(15);+/// 给对手机的一次调用加时限:卡住的服务不能把调用方(守护进程持锁时)一起卡死pub(crate) async fn limit<T>(what: &str, d: Duration, f: impl Future<Output = Result<T>>) -> Result<T> {tokio::time::timeout(d, f).await.map_err(|_| DeviceError::Timeout(format!("{what}({} 秒)", d.as_secs())))?@@ -178,16 +181,8 @@ pub fn usbmuxd_addr() -> UsbmuxdAddr {UsbmuxdAddr::from_env_var().unwrap_or_default()}-/// 检查 sysfs 里是否有 Apple(05ac)USB 设备。容器无 udev 时用来判断 usbmuxd 是否漏掉了设备。-/// `root` 一般是 `/sys/bus/usb/devices`。-pub fn apple_usb_present(root: &Path) -> bool {- let Ok(entries) = std::fs::read_dir(root) else { return false };- entries- .flatten()- .any(|e| std::fs::read_to_string(e.path().join("idVendor")).map(|v| v.trim() == "05ac").unwrap_or(false))-}-/// sysfs 里 iPhone/iPad/iPod 的台数:厂商号 05ac、产品名以 iPhone/iPad/iPod 开头(Apple 键盘之类的配件不算)。+/// `root` 一般是 `/sys/bus/usb/devices`。/// 接着几台时和 usbmuxd 认到的台数比,才看得出「新插的那台没被认出来」pub fn ios_usb_count(root: &Path) -> usize {let Ok(entries) = std::fs::read_dir(root) else { return 0 };@@ -205,11 +200,11 @@ pub fn ios_usb_count(root: &Path) -> usize {/// Linux 上 USB 设备在 sysfs 里的目录pub const SYSFS_USB: &str = "/sys/bus/usb/devices";-/// 宿主机 USB 上有没有 iPhone/iPad:Linux 读 sysfs([`apple_usb_present`]),macOS 查 IORegistry。+/// 宿主机 USB 上有没有 iPhone/iPad:Linux 读 sysfs([`ios_usb_count`]),macOS 查 IORegistry。/// 判断不了(其他系统、`ioreg` 运行失败)返回 `None`,调用方应跳过这项检查而不是当成「没有」。-pub async fn host_apple_usb_present() -> Option<bool> {+pub async fn host_ios_usb_present() -> Option<bool> {if cfg!(target_os = "linux") {- return Some(apple_usb_present(Path::new(SYSFS_USB)));+ return Some(ios_usb_count(Path::new(SYSFS_USB)) > 0);}if !cfg!(target_os = "macos") {return None;@@ -230,15 +225,18 @@ fn ioreg_has_ios_device(out: &str) -> bool {/// usbmuxd 看到的 USB 设备(不含网络设备)。usbmuxd 没在运行时返回错误。pub async fn list_devices() -> Result<Vec<UsbDevice>> {- // 不用 UsbmuxdConnection::default():它固定连 /var/run/usbmuxd,不看 USBMUXD_SOCKET_ADDRESS- let mut mux = usbmuxd_addr().connect(0).await?;- Ok(mux- .get_devices()- .await?- .into_iter()- .filter(|d| matches!(d.connection_type, Connection::Usb))- .map(|d| UsbDevice { udid: d.udid, device_id: d.device_id })- .collect())+ limit("列出 usbmuxd 设备", QUERY, async {+ // 不用 UsbmuxdConnection::default():它固定连 /var/run/usbmuxd,不看 USBMUXD_SOCKET_ADDRESS+ let mut mux = usbmuxd_addr().connect(0).await?;+ Ok(mux+ .get_devices()+ .await?+ .into_iter()+ .filter(|d| matches!(d.connection_type, Connection::Usb))+ .map(|d| UsbDevice { udid: d.udid, device_id: d.device_id })+ .collect())+ })+ .await}/// 一台设备的句柄。只持有 usbmuxd provider,每次调用按需新建连接;隧道见 [`Device::open_tunnel`]。@@ -290,30 +288,40 @@ impl Device {/// usbmuxd 里有没有这台手机的配对记录。只有「没有记录」算 false;连不上 usbmuxd 等错误照常返回,/// 免得 usbmuxd 抖一下就让状态变成「请在手机上点信任」pub async fn paired(&self) -> Result<bool> {- let mut mux = self.provider.addr.connect(0).await?;- match mux.get_pair_record(&self.udid).await {- Ok(_) => Ok(true),- // 没有记录时 usbmuxd 的应答里没有 PairRecordData;记录损坏同样需要重新配对- Err(IdeviceError::UnexpectedResponse(_)) => Ok(false),- Err(e) => Err(e.into()),- }+ limit("查配对记录", QUERY, async {+ let mut mux = self.provider.addr.connect(0).await?;+ match mux.get_pair_record(&self.udid).await {+ Ok(_) => Ok(true),+ // 没有记录时 usbmuxd 的应答里没有 PairRecordData;记录损坏同样需要重新配对+ Err(IdeviceError::UnexpectedResponse(_)) => Ok(false),+ Err(e) => Err(e.into()),+ }+ })+ .await}/// 发起配对:手机上弹「信任此电脑」。用户还没点时返回 [`DeviceError::PairingPending`],调用方应轮询重试。/// 成功后配对记录交给 usbmuxd 保存(容器里即 `/var/lib/lockdown`)。pub async fn pair(&self, host_name: &str) -> Result<()> {- let mut mux = self.provider.addr.connect(0).await?;- let buid = mux.get_buid().await?;- let mut lockdown = LockdownClient::connect(&*self.provider).await?;- let host_id = uuid::Uuid::new_v4().to_string().to_uppercase();- let record = lockdown.pair_once(host_id, buid, Some(host_name)).await?;- let mut mux = self.provider.addr.connect(0).await?;- mux.save_pair_record(&self.udid, record.serialize()?).await?;- Ok(())+ limit("配对", Duration::from_secs(30), async {+ let mut mux = self.provider.addr.connect(0).await?;+ let buid = mux.get_buid().await?;+ let mut lockdown = LockdownClient::connect(&*self.provider).await?;+ let host_id = uuid::Uuid::new_v4().to_string().to_uppercase();+ let record = lockdown.pair_once(host_id, buid, Some(host_name)).await?;+ let mut mux = self.provider.addr.connect(0).await?;+ mux.save_pair_record(&self.udid, record.serialize()?).await?;+ Ok(())+ })+ .await}/// 名称、型号、iOS 版本(不需要配对)pub async fn info(&self) -> Result<DeviceInfo> {+ limit("读设备信息", QUERY, self.info_inner()).await+ }++ async fn info_inner(&self) -> Result<DeviceInfo> {let mut lockdown = LockdownClient::connect(&*self.provider).await?;let mut get = async |key: &str| -> String {match lockdown.get_value(Some(key), None).await {@@ -335,16 +343,23 @@ impl Device {/// 手机上装着的全部描述文件(.mobileprovision 原始内容,经 misagent 读)。装 App 时随包带的描述文件会留在这里,/// 用它判断「这台手机上的 WDA 还能用多久」:同一个 Apple ID 给几台手机先后签过,每台装的是各自那一次签的pub async fn installed_profiles(&self) -> Result<Vec<Vec<u8>>> {- Ok(MisagentClient::connect(&*self.provider).await?.copy_all().await?)+ limit("读描述文件", QUERY, async { Ok(MisagentClient::connect(&*self.provider).await?.copy_all().await?) })+ .await}pub async fn developer_mode_enabled(&self) -> Result<bool> {- Ok(AmfiClient::connect(&*self.provider).await?.get_developer_mode_status().await?)+ limit("查开发者模式", QUERY, async {+ Ok(AmfiClient::connect(&*self.provider).await?.get_developer_mode_status().await?)+ })+ .await}/// 让「设置 → 隐私与安全性」里出现开发者模式开关(打开仍需用户在手机上操作)pub async fn reveal_developer_mode(&self) -> Result<()> {- Ok(AmfiClient::connect(&*self.provider).await?.reveal_developer_mode_option_in_ui().await?)+ limit("显示开发者模式开关", QUERY, async {+ Ok(AmfiClient::connect(&*self.provider).await?.reveal_developer_mode_option_in_ui().await?)+ })+ .await}/// 建立 CoreDeviceProxy 用户态隧道并完成 RSD 握手。锁屏时报 [`DeviceError::PasswordProtected`]。@@ -362,21 +377,28 @@ impl Device {/// 已安装的 App。`include_system` 为 false 只列用户 App,为 true 只列系统 App(与 toolkit 一致)。pub async fn list_apps(&self, include_system: bool) -> Result<Vec<AppInfo>> {- let mut proxy = InstallationProxyClient::connect(&*self.provider).await?;- let kind = if include_system { "System" } else { "User" };- Ok(apps::parse_apps(proxy.get_apps(Some(kind), None).await?))+ limit("列出 App", Duration::from_secs(30), async {+ let mut proxy = InstallationProxyClient::connect(&*self.provider).await?;+ let kind = if include_system { "System" } else { "User" };+ Ok(apps::parse_apps(proxy.get_apps(Some(kind), None).await?))+ })+ .await}/// 经 usbmuxd 直连手机上的 TCP 端口(`iphone-control wda-bridge` 用)pub async fn connect_port(&self, port: u16) -> Result<Box<dyn idevice::ReadWrite>> {- let dev = self.provider.connect(port).await?;+ let dev = limit("连接手机端口", QUERY, async { Ok(self.provider.connect(port).await?) }).await?;dev.get_socket().ok_or_else(|| DeviceError::Idevice("连接没有套接字".into()))}/// 上传并安装 .ipa 或 .app 目录pub async fn install(&self, package: &Path) -> Result<()> {- idevice::utils::installation::install_package(&*self.provider, package, None).await?;- Ok(())+ // 含上传几十 MB 的包,USB 2 上也就一两分钟+ limit("安装", Duration::from_secs(600), async {+ idevice::utils::installation::install_package(&*self.provider, package, None).await?;+ Ok(())+ })+ .await}}@@ -426,10 +448,8 @@ impl Tunnel {/// HID 会话;没有就开一个:先启动显示媒体流(HID 的授权闸门),再连 universalhidservice 和 indigopub async fn hid(&mut self, screen: ScreenSize) -> Result<&mut HidSession> {if self.hid.is_none() {- let h = limit("开启 HID 会话", Duration::from_secs(20), async {- HidSession::open(&mut self.adapter, &mut self.handshake, screen).await- })- .await?;+ // 各步自带时限(见 HidSession::open):不能在这里整体取消,否则起来一半的媒体流没人停+ let h = HidSession::open(&mut self.adapter, &mut self.handshake, screen).await?;self.hid = Some(h);}let h = self.hid.as_mut().expect("刚建好");@@ -495,7 +515,6 @@ mod tests {// 接口目录没有 idVendorstd::fs::create_dir_all(root.join("5-1:1.0")).unwrap();assert_eq!(ios_usb_count(&root), 2);- assert!(apple_usb_present(&root));std::fs::remove_dir_all(&root).unwrap();assert_eq!(ios_usb_count(&root), 0);}diff --git a/crates/ictl-device/src/media.rs b/crates/ictl-device/src/media.rsindex 1659c79..a0c6708 100644--- a/crates/ictl-device/src/media.rs+++ b/crates/ictl-device/src/media.rs@@ -14,7 +14,12 @@ use idevice::{tcp::handle::{AdapterHandle, UdpSocketHandle},};-use crate::{DeviceError, Result};+use std::time::Duration;++use crate::{DeviceError, Result, limit};++/// 每一步的时限。超时不能在外层直接取消:音频流可能已经起来了,必须走到 stop+const STEP: Duration = Duration::from_secs(10);/// 我们(控制端)支持的特性,不是设备的。Device Hub 屏幕共享发 140;/// 发设备的掩码会让协商出无效的视频配置。@@ -29,9 +34,7 @@ pub(crate) struct ScreenMediaStream {impl ScreenMediaStream {pub async fn stop(mut self) {- if let Err(e) = self.client.stop_media_stream().await {- tracing::debug!("stop_media_stream: {e}");- }+ stop(&mut self.client).await;}}@@ -42,8 +45,10 @@ pub(crate) async fn start() -> Result<ScreenMediaStream> {let fail = |what: &str, e: &dyn std::fmt::Display| DeviceError::Idevice(format!("媒体流 {what}:{e}"));- let mut client =- DisplayServiceClient::connect_rsd(adapter, handshake).await.map_err(|e| fail("连接 displayservice", &e))?;+ let mut client = limit("连接 displayservice", STEP, async {+ DisplayServiceClient::connect_rsd(adapter, handshake).await.map_err(|e| fail("连接 displayservice", &e))+ })+ .await?;let audio_udp = adapter.bind_udp(0).await.map_err(|e| fail("绑定音频 UDP", &e))?;let video_udp = adapter.bind_udp(0).await.map_err(|e| fail("绑定视频 UDP", &e))?;let receiver_ip = adapter.host_ip().to_string();@@ -73,7 +78,6 @@ pub(crate) async fn start(CLIENT_SUPPORTED_FEATURES,session,);- client.start_media_stream(audio_params).await.map_err(|e| fail("启动音频流", &e))?;let call_id = uuid::Uuid::new_v4().to_string().to_uppercase();let ssrc = uuid::Uuid::new_v4().as_u128() as u32;@@ -88,11 +92,24 @@ pub(crate) async fn start(display_id,session,);- if let Err(e) = client.start_media_stream(params).await {- // 音频流已经起来了,要停掉:stopAll 连同会话一起结束,否则手机端一直挂着- let _ = client.stop_media_stream().await;- return Err(fail("启动视频流", &e));+ let started = limit("启动媒体流", STEP * 2, async {+ client.start_media_stream(audio_params).await.map_err(|e| fail("启动音频流", &e))?;+ client.start_media_stream(params).await.map_err(|e| fail("启动视频流", &e))+ })+ .await;+ if let Err(e) = started {+ // 音频流可能已经起来了(包括超时的情况),要停掉:stopAll 连同会话一起结束,否则手机端一直挂着+ stop(&mut client).await;+ return Err(e);}Ok(ScreenMediaStream { client, _audio_udp: audio_udp, _video_udp: video_udp })}++async fn stop(client: &mut DisplayServiceClient<Box<dyn ReadWrite>>) {+ match tokio::time::timeout(STEP, client.stop_media_stream()).await {+ Ok(Ok(_)) => {}+ Ok(Err(e)) => tracing::debug!("stop_media_stream: {e}"),+ Err(_) => tracing::warn!("停止屏幕媒体流超时,手机上可能还挂着屏幕共享会话"),+ }+}diff --git a/crates/ictl-mcp/Cargo.toml b/crates/ictl-mcp/Cargo.tomlindex 01471d8..14836a0 100644--- a/crates/ictl-mcp/Cargo.toml+++ b/crates/ictl-mcp/Cargo.toml@@ -7,7 +7,7 @@ license.workspace = truepublish.workspace = truerepository.workspace = truehomepage.workspace = true-description = "MCP stdio 服务(13 个 iphone_* 工具)"+description = "MCP stdio 服务(17 个 iphone_* 工具)"[dependencies]ictl-protocol.workspace = truediff --git a/crates/ictl-mcp/src/lib.rs b/crates/ictl-mcp/src/lib.rsindex 5667c83..87ade69 100644--- a/crates/ictl-mcp/src/lib.rs+++ b/crates/ictl-mcp/src/lib.rs@@ -18,11 +18,11 @@ use rmcp::{};use serde_json::{Map, Value, json};-/// 服务说明(发给客户端的 instructions),与 toolkit 一致-pub const INSTRUCTIONS: &str = "控制一台通过 USB 连接的真实 iPhone。坐标单位是点(pt),与 iphone_screenshot 图像像素一致。\+/// 服务说明(发给客户端的 instructions):toolkit 的那段,加上自动解锁范围、多设备的说明+pub const INSTRUCTIONS: &str = "控制一台通过 USB 连接的真实 iPhone(或 iPad)。坐标单位是点(pt),与 iphone_screenshot 图像像素一致。\操作前先用 iphone_screenshot 或 iphone_list_elements 看清屏幕;能按名字点就优先用 iphone_tap_element。\游戏、地图等界面没有元素树,只能看截图按坐标操作;小图标、小字看不清时用 iphone_screenshot 的区域放大。\-配置了锁屏密码时,各操作工具会先自动解锁。每次操作后再截图确认结果。\+配置了锁屏密码时,截图、读元素在内的各工具都会先自动解锁。每次操作后再截图确认结果。\涉及付款、删除、发送消息、修改账号或隐私设置的操作,先向用户确认。\省时间:操作类工具可带 then=elements 或 then=screenshot,等界面稳定后顺带返回操作后的界面,不用再单独调一次;\几步确定的连续操作(按键、逐级点菜单、填表)用 iphone_batch 一次发完;等页面加载用 iphone_wait_for,不要反复截图。\@@ -130,7 +130,8 @@ WDA 不可用时会说明哪些功能受影响(读元素、按名字点击、启看不清小图标、小字时,传 x/y/width/height(点,四个要一起给)放大这块区域:从原始高清截图裁剪,小区域再额外放大。\返回文字里有放大倍数,图中坐标换算回屏幕点:x + 像素/倍数。\n\n\何时用:游戏、地图、图片等没有元素树的界面,或要确认画面效果时。只想知道有哪些按钮、文字,iphone_list_elements 更快更省上下文。\-操作后要看结果时,优先给操作工具带 then=screenshot。WDA 不可用时改用 CoreDevice 截图(说明里注明「HID」)。只读。"+操作后要看结果时,优先给操作工具带 then=screenshot。WDA 不可用时改用 CoreDevice 截图(iOS 27 起,说明里注明「HID」)。\+只读:不改变界面,但配置了锁屏密码时会先解锁。".into(),schema(json!({"x": num("区域左上角 x(点)"), "y": num("区域左上角 y(点)"), "width": num("区域宽(点)"), "height": num("区域高(点)")}),@@ -143,7 +144,8 @@ WDA 不可用时会说明哪些功能受影响(读元素、按名字点击、启"列出屏幕上带文字的界面元素,每行一个:类型、标签、名字、值、中心点坐标、尺寸(点)。\n\n\何时用:找按钮、输入框、列表项的文字和位置,比截图快、省上下文;找到后用 iphone_tap_element 按文字点。\游戏、地图等没有元素树的界面这里是空的,改用 iphone_screenshot。\n\n\-注意:按坐标判断是否在屏幕内,被弹窗遮住的元素也可能列出来,不确定时截图核对。需要 WDA。只读。"+注意:按坐标判断是否在屏幕内,被弹窗遮住的元素也可能列出来,不确定时截图核对。需要 WDA。\+只读:不改变界面,但配置了锁屏密码时会先解锁。".into(),schema(json!({@@ -162,7 +164,7 @@ WDA 不可用时会说明哪些功能受影响(读元素、按名字点击、启何时用:目标没有文字(图标、图片)、在游戏或地图里,或 iphone_list_elements 里找不到它时。\带文字的按钮、列表项优先用 iphone_tap_element,界面布局变了也点得准。按住用 iphone_long_press,滚动用 iphone_swipe。\n\n\行为:单指按下约 0.05 秒后抬起,点一次。不检查坐标上是什么,点之前先截图确认位置。\-WDA 不可用时改用 CoreDevice HID(结果里注明「经 HID」)。",+WDA 不可用时改用 CoreDevice HID(iOS 27 起;结果里注明「经 HID」)。","已点击 (120,300)",true,),@@ -218,7 +220,7 @@ WDA 不可用时改用 CoreDevice HID(结果里注明「经 HID」)。",何时用:滚动列表或页面、左右翻页、拖动滑块。向上滑看下面的内容:from_y 大、to_y 小(例如 y 从 700 滑到 300);\向左滑看右边的内容:from_x 大、to_x 小。点击用 iphone_tap,原地按住用 iphone_long_press。\n\n\行为:seconds 越小滑得越快,快滑会带惯性多滚一段;要精确移动(滑块)把 seconds 调到 1 秒左右。\-滑完会等列表停止滚动(最多 2.5 秒)再返回,还在滚就在结果里说明。WDA 不可用时改用 CoreDevice HID。",+滑完会等列表停止滚动(最多 2.5 秒)再返回,还在滚就在结果里说明。WDA 不可用时改用 CoreDevice HID(iOS 27 起)。","已滑动 (215,700) → (215,300)",true,),@@ -241,7 +243,7 @@ WDA 不可用时改用 CoreDevice HID(结果里注明「经 HID」)。",何时用:搜索框、表单、聊天框等。要先点中输入框让键盘弹出;屏幕上没有键盘时报错,什么都不输。\回车可能会发送消息或提交表单,发送前先向用户确认。\n\n\行为:输完会读回输入框核对,少了结尾几个字会自动补上;对不上就报错,也不按回车。\-WDA 不可用时改用 HID,只能输入美式键盘上的英文和符号。",+WDA 不可用时改用 HID(iOS 27 起),只能输入美式键盘上的英文和符号。","已输入 4 个字符,并按了回车",true,),@@ -328,7 +330,7 @@ WDA 不可用时改用 HID,只能输入美式键盘上的英文和符号。","iphone_wait_for","等包含某段文字的界面元素出现(例如页面加载完、搜索结果出来、弹窗出现),出现就立即返回找到的元素和用时;超时报错。\n\n\何时用:操作后要等加载时代替反复截图轮询,每 0.3 秒查一次,不占上下文。输入框里的字不算(刚输入的搜索词不会被当成结果)。\-需要 WDA。只读,不改变手机状态。"+需要 WDA。只读:不改变界面,但配置了锁屏密码时会先解锁。".into(),schema(json!({@@ -352,7 +354,8 @@ WDA 不可用时改用 HID,只能输入美式键盘上的英文和符号。","改为控制另一台设备,之后所有工具都作用在它上面,守护进程重启后还记得。device 是 UDID 或设备名(设备名包含这段文字且只有一台也行),\auto 表示取消选定、改回自动选(正在控制的那台断开才换)。\n\n\何时用:接着多台设备、要操作的不是正在控制的那台。先用 iphone_list_devices 看有哪几台。\n\n\-行为:切换后要在新设备上拉起 WDA(10~60 秒),期间读界面、按名字点击等用不了,先用 iphone_status 确认就绪。\+行为:切换后要在新设备上拉起 WDA(10~60 秒),期间读界面、按名字点击等用不了,先用 iphone_status 确认就绪;\+这台从没装过 WDA 时起不来,要请用户运行 iphone-control setup。\自动解锁按设备分开存密码,新设备没设就不会自动解锁。设了 IPHONE_UDID 时不能切换。\n\n\返回:一行结果文字,例如「已切换到 Derrors 的 iPad(iPad11,1 iOS 26.6.1,00008020-…)」。".into(),@@ -569,7 +572,7 @@ pub fn batch_steps(args: &Map<String, Value>) -> Result<Vec<Step>, String> {/// tap_element 的结果是不是「没点到」(没找到、index 超出匹配个数、或整个被别的东西盖住)pub fn tap_missed(text: &str) -> bool {- text.starts_with("没找到") || text.starts_with("只匹配到") || text.starts_with("被挡住")+ protocol::TAP_MISSED.iter().any(|p| text.starts_with(p))}/// 不带 then 的操作做完后要不要查系统弹窗(弹窗挡着时操作都落在弹窗上,WDA 照样报成功)。@@ -612,8 +615,19 @@ impl ServerHandler for McpServer {async fn call_tool(&self,request: CallToolRequestParams,- _context: RequestContext<RoleServer>,+ context: RequestContext<RoleServer>,) -> Result<CallToolResponse, ErrorData> {+ // rmcp 收到取消通知只是置这个令牌,不会中止处理:自己停下。丢掉进行中的调用会断开到守护进程的连接,+ // 守护进程那边还在排队的请求随之放弃(protocol::call),iphone_batch 剩下的步骤也不再执行+ tokio::select! {+ r = self.call_tool_inner(request) => r,+ _ = context.ct.cancelled() => Ok(to_result(Response::error("调用已取消")).into()),+ }+ }+}++impl McpServer {+ async fn call_tool_inner(&self, request: CallToolRequestParams) -> Result<CallToolResponse, ErrorData> {let args = request.arguments.unwrap_or_default();let then = match parse_then(&args) {Ok(t) => t,@@ -636,17 +650,22 @@ impl ServerHandler for McpServer {}.into())}-}-impl McpServer {async fn call(&self, req: &Request) -> Response {+ self.call_on(req, None).await+ }++ /// `expect_udid`:守护进程正在控制的不是这台就不执行(见 [`protocol::EXPECT_UDID`])+ async fn call_on(&self, req: &Request, expect_udid: Option<&str>) -> Response {// 守护进程正忙(例如在自动解锁)时会排队;最多等 150 秒,免得 agent 一直挂着- protocol::call(&self.socket, req, Some(Duration::from_secs(150))).await.unwrap_or_else(|e| {- Response::error(format!(- "连不上守护进程({}):{e};确认守护进程在运行(容器部署看 iphone-control 容器)",- self.socket.display()- ))- })+ protocol::call_expecting(&self.socket, req, Some(Duration::from_secs(150)), expect_udid).await.unwrap_or_else(+ |e| {+ Response::error(format!(+ "连不上守护进程({}):{e};确认守护进程在运行(容器部署看 iphone-control 容器)",+ self.socket.display()+ ))+ },+ )}/// 操作完成后:按 then 等界面稳定,再附上元素列表或截图(等稳定时顺带提醒弹窗)。@@ -659,7 +678,7 @@ impl McpServer {if then == Then::None {// 结果里已经说了有弹窗(启动 App 被挡)就不再查if alert_check- && !text.contains("系统弹窗")+ && !text.contains(protocol::ALERT_BLOCKING)&& let Response::Text { text: t } = self.call(&Request::AlertCheck).await{text += &t;@@ -695,6 +714,13 @@ impl McpServer {}}+ /// 守护进程正在控制的设备的 UDID;读不到(没接设备、连不上)返回 None+ async fn controlled_udid(&self) -> Option<String> {+ let Response::Text { text } = self.call(&Request::Daemon).await else { return None };+ let v: Value = serde_json::from_str(&text).ok()?;+ v["device"]["udid"].as_str().filter(|u| !u.is_empty()).map(str::to_owned)+ }+/// 按顺序执行;某一步出错就停,说明是第几步、后面几步没执行。出错时也按 then 附上当前界面,方便看停在哪async fn batch(&self, args: &Map<String, Value>, then: ThenOpts) -> CallToolResult {let steps = match batch_steps(args) {@@ -702,6 +728,8 @@ impl McpServer {Err(e) => return to_result(Response::error(e)),};let total = steps.len();+ // 每一步都要求还是开始时控制的那台:自动选设备时拔掉它会改控另一台,剩下的步骤不能落到那台上+ let udid = self.controlled_udid().await;let mut lines = Vec::new();// 最后一步是不是需要查弹窗的操作let mut check = false;@@ -712,7 +740,7 @@ impl McpServer {tokio::time::sleep(d).await;lines.push(format!("{n}. wait → 等了 {} 秒", d.as_secs_f64()));}- Step::Request { tool, req } => match self.call(&req).await {+ Step::Request { tool, req } => match self.call_on(&req, udid.as_deref()).await {// 按名字没点到(toolkit 兼容:单独调用时是普通结果)在批量里要停下:后面的步骤都建立在它点中的前提上Response::Text { text } if tool == "iphone_tap_element" && tap_missed(&text) => {lines.push(format!("{n}. {tool} → {text}"));diff --git a/crates/ictl-protocol/src/lib.rs b/crates/ictl-protocol/src/lib.rsindex e6cbf45..edadb9e 100644--- a/crates/ictl-protocol/src/lib.rs+++ b/crates/ictl-protocol/src/lib.rs@@ -169,20 +169,53 @@ impl Request {}}-/// 发一个请求、读一个响应(客户端用)。`timeout` 为 None 时一直等(例如 `sign` 要等签名装完)+/// 工具结果里报告系统弹窗挡着屏幕的固定写法(后面接「弹窗文字」)。MCP 端据此判断结果里是否已经报过弹窗,+/// 不能只找「系统弹窗」几个字:按名字点到的元素文字里也可能有+pub const ALERT_BLOCKING: &str = "屏幕上有系统弹窗";++/// `iphone_tap_element` 没点到时结果开头的几种写法(不算出错,单独调用时是普通结果;批量里要停下)+pub const TAP_MISSED: [&str; 3] = ["没找到", "只匹配到", "被挡住"];++/// 请求里带上这个键(值为 true):客户端发完请求不半关闭连接,守护进程据此把「读到 EOF」当成调用方已经走了,+/// 还在排队等设备的请求就不再执行。旧版本的客户端发完就半关闭、不带这个键,守护进程对它们照旧处理完。+/// 放在请求对象里而不是改协议格式:旧版本守护进程会忽略这个多出来的键+pub const CANCEL_ON_CLOSE: &str = "cancel_on_close";++/// 请求里带上这个键(值为 UDID):守护进程正在控制的不是这台就不执行。`iphone_batch` 用它防止中途换了设备+/// (自动选设备时拔掉正在控制的那台,会改控另一台)后,剩下的步骤落到另一台上+pub const EXPECT_UDID: &str = "expect_udid";++/// 发一个请求、读一个响应(客户端用)。`timeout` 为 None 时一直等(例如 `sign` 要等签名装完)。+/// 返回之前被丢掉(超时、调用方取消)时连接随之关闭,守护进程会放弃还在排队的这个请求pub async fn call(socket: &std::path::Path,req: &Request,timeout: Option<std::time::Duration>,+) -> std::io::Result<Response> {+ call_expecting(socket, req, timeout, None).await+}++/// 同 [`call`];`expect_udid` 见 [`EXPECT_UDID`]+pub async fn call_expecting(+ socket: &std::path::Path,+ req: &Request,+ timeout: Option<std::time::Duration>,+ expect_udid: Option<&str>,) -> std::io::Result<Response> {use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};let exchange = async {let stream = tokio::net::UnixStream::connect(socket).await?;let (r, mut w) = stream.into_split();- let mut line = serde_json::to_string(req)?;+ let mut v = serde_json::to_value(req)?;+ if let Some(o) = v.as_object_mut() {+ o.insert(CANCEL_ON_CLOSE.into(), true.into());+ if let Some(u) = expect_udid {+ o.insert(EXPECT_UDID.into(), u.into());+ }+ }+ let mut line = v.to_string();line.push('\n');w.write_all(line.as_bytes()).await?;- w.shutdown().await?;let mut resp = String::new();BufReader::new(r).read_line(&mut resp).await?;serde_json::from_str(&resp).map_err(std::io::Error::other)@@ -211,4 +244,13 @@ mod tests {let e: Response = serde_json::from_str(r#"{"kind":"error","message":"x"}"#).unwrap();assert_eq!(e, Response::error("x"));}++ /// 旧版本守护进程直接反序列化请求:多出来的 cancel_on_close 键不能让它报错(含没有字段的请求)+ #[test]+ fn extra_cancel_key_is_ignored_when_parsing() {+ for s in [r#"{"op":"status","cancel_on_close":true}"#, r#"{"op":"tap","x":1.0,"y":2.0,"cancel_on_close":true}"#]+ {+ serde_json::from_str::<Request>(s).unwrap_or_else(|e| panic!("{s}: {e}"));+ }+ }}diff --git a/crates/ictl-sign/src/ipa.rs b/crates/ictl-sign/src/ipa.rsindex 4abb140..0043d45 100644--- a/crates/ictl-sign/src/ipa.rs+++ b/crates/ictl-sign/src/ipa.rs@@ -33,14 +33,15 @@ pub fn pack(root: &Path, out: &Path) -> io::Result<()> {/// 文件原样复制压缩数据和权限位,不解压。目录项重新写:Appium 的包里目录项的类型位记成了普通文件pub fn from_app_zip(src: &Path, out: &Path) -> io::Result<()> {let mut zip = ZipArchive::new(File::open(src)?).map_err(io::Error::other)?;- if !zip.file_names().any(|n| n.split('/').next().is_some_and(|top| top.ends_with(".app"))) {+ // zip 9 起条目名不合法(例如带 `..`)时给的是错误:这种条目不算+ if !zip.file_names().flatten().any(|n| n.split('/').next().is_some_and(|top| top.ends_with(".app"))) {return Err(io::Error::new(io::ErrorKind::NotFound, "zip 根目录下没有 .app"));}let mut w = ZipWriter::new(File::create(out)?);w.add_directory("Payload/", SimpleFileOptions::default().unix_permissions(0o755)).map_err(io::Error::other)?;for i in 0..zip.len() {let f = zip.by_index_raw(i).map_err(io::Error::other)?;- let name = format!("Payload/{}", f.name());+ let name = format!("Payload/{}", f.name().map_err(io::Error::other)?);if f.is_dir() {let mode = f.unix_mode().map_or(0o755, |m| m & 0o7777);w.add_directory(name, SimpleFileOptions::default().unix_permissions(mode)).map_err(io::Error::other)?;diff --git a/crates/ictl-sign/src/profile.rs b/crates/ictl-sign/src/profile.rsindex f9de005..4279c0c 100644--- a/crates/ictl-sign/src/profile.rs+++ b/crates/ictl-sign/src/profile.rs@@ -6,8 +6,6 @@ use std::time::SystemTime;#[derive(Debug, Clone, PartialEq)]pub struct Profile {- pub name: String,- pub team_id: String,pub expires: SystemTime,pub devices: Vec<String>,pub get_task_allow: bool,@@ -25,14 +23,6 @@ impl Profile {let d = v.as_dictionary()?;let ent = d.get("Entitlements").and_then(|e| e.as_dictionary());Some(Self {- name: d.get("Name").and_then(|v| v.as_string()).unwrap_or_default().to_owned(),- team_id: d- .get("TeamIdentifier")- .and_then(|v| v.as_array())- .and_then(|a| a.first())- .and_then(|v| v.as_string())- .unwrap_or_default()- .to_owned(),expires: d.get("ExpirationDate").and_then(|v| v.as_date()).map(SystemTime::from)?,devices: d.get("ProvisionedDevices")@@ -91,7 +81,6 @@ pub(crate) mod tests {fn parses_profile_inside_cms_wrapper() {let exp = SystemTime::UNIX_EPOCH + Duration::from_secs(2_000_000_000);let p = Profile::parse(&fake(exp, &["00000000-AAAA"])).unwrap();- assert_eq!(p.team_id, "TEAM000000");assert_eq!(p.devices, ["00000000-AAAA"]);assert!(p.get_task_allow);assert_eq!(p.expires, exp);diff --git a/crates/ictl-unlock/src/fake.rs b/crates/ictl-unlock/src/fake.rsindex 88a9e2d..d4fa4bb 100644--- a/crates/ictl-unlock/src/fake.rs+++ b/crates/ictl-unlock/src/fake.rs@@ -37,6 +37,8 @@ const IPAD_TOUCHID_XML: &str = include_str!("../../ictl-wda/tests/fixtures/ipad-const IPAD_PIN_XML: &str = include_str!("../../ictl-wda/tests/fixtures/ipad-passcode-landscape.xml");/// Home 键在左的横屏:树里的坐标和上面中心对称,换算到屏幕上键位不变const IPAD_TOUCHID_LEFT_XML: &str = include_str!("../../ictl-wda/tests/fixtures/ipad-touchid-landscape-home-left.xml");+/// iPad 竖屏锁屏(上滑之前)。去掉「按下主屏幕按钮以解锁」那行就是熄屏、有通知时的样子:认不出是锁屏+const IPAD_LOCK_XML: &str = include_str!("../../ictl-wda/tests/fixtures/ipad-lockscreen-portrait.xml");const IPAD_PIN_LEFT_XML: &str = include_str!("../../ictl-wda/tests/fixtures/ipad-passcode-landscape-home-left.xml");/// ipad-passcode-landscape.xml 里各键按 Home 键在右的横屏换算到屏幕上的中心点(真机截图对得上)const IPAD_KEYS: [(i64, i64); 10] = [@@ -92,12 +94,20 @@ pub struct FakeLockScreen {ipad: Option<&'static str>,/// iPad 横屏时 Home 键在左(默认在右)ipad_home_left: bool,+ /// iPad 模式:上滑之前的锁屏上没有「按下主屏幕按钮以解锁」(熄屏、有通知时),树里没有锁的标记+ ipad_hint_hidden: bool,}impl FakeLockScreen {pub fn new(code: &str) -> Self {let st = State { locked: true, idle: (10.0, 2.0), ..Default::default() };- Self { code: code.bytes().map(|b| b - b'0').collect(), st: Mutex::new(st), ipad: None, ipad_home_left: false }+ Self {+ code: code.bytes().map(|b| b - b'0').collect(),+ st: Mutex::new(st),+ ipad: None,+ ipad_home_left: false,+ ipad_hint_hidden: false,+ }}/// iPad 横屏(Home 键在右)、Touch ID;WDA 报的方向是 `orientation`@@ -110,6 +120,11 @@ impl FakeLockScreen {Self { ipad_home_left: true, ..Self::ipad_touch_id(code, orientation) }}+ /// iPad 锁屏上没有解锁提示(见 `ipad_hint_hidden`)+ pub fn ipad_lock_screen_without_hint(code: &str, orientation: &'static str) -> Self {+ Self { ipad_hint_hidden: true, ..Self::ipad_touch_id(code, orientation) }+ }+pub fn state(&self) -> State {self.st.lock().unwrap().clone()}@@ -271,6 +286,12 @@ impl FakeLockScreen {if s.locked {let field = format!("共{}位数,已输入{}位", self.code.len(), s.entered.len());let pin = s.shown && s.passcode_requested;+ if self.ipad_hint_hidden && !s.shown {+ return (+ 200,+ json!({"value": IPAD_LOCK_XML.replace("call-to-action-label", "x"), "sessionId": "S"}),+ );+ }let xml = match (self.ipad, self.ipad_home_left, pin) {(None, ..) => LOCK_XML,(Some(_), false, true) => IPAD_PIN_XML,diff --git a/crates/ictl-unlock/src/lib.rs b/crates/ictl-unlock/src/lib.rsindex cd10c79..7ee15bd 100644--- a/crates/ictl-unlock/src/lib.rs+++ b/crates/ictl-unlock/src/lib.rs@@ -1,6 +1,6 @@//! 锁屏自动解锁(默认关闭,需显式配置密码文件)。//!-//! 规则全部来自 toolkit 实测(docs/dev/capability-matrix.md §5):+//! 规则来自 toolkit 实测,之后按 iOS 26/27 的 iPhone、iPad 真机补充(以下是现行规则)://! 1. 先读 `/wda/locked`,没锁直接返回;WDA 不可用也直接返回(交给后面的调用去报错)//! 2. 每轮固定:按 Home → 等 1.0s → 底部上滑 → 等 1.5s。不以「树里有键盘」判断:键盘收起时按键元素也常驻树中。//! 有 Touch ID 的机型上滑后是「触控 ID」提示,先点「使用密码」再等 1.5s 调出键盘。@@ -75,10 +75,6 @@ impl Default for Timing {}pub const FIRST_DIGIT_ROUNDS: u32 = 3;-/// 解锁期间的等待上限(不能是 0:唤醒会失败)-pub const UNLOCK_IDLE: IdleSettings = IdleSettings::QUICK;-/// WDA 的默认等待设置(上次没恢复时用它恢复)-pub const WDA_DEFAULT_IDLE: IdleSettings = IdleSettings::DEFAULT;pub struct UnlockConfig {pub passcode_file: PathBuf,@@ -117,20 +113,21 @@ pub async fn ensure_unlocked<T: Transport>(wda: &mut WdaClient<T>, cfg: &UnlockClet code = passcode(cfg);// WDA 说锁了且能自动解锁:不先核对(熄屏锁屏时第一个无障碍查询要等约 8 秒),直接进解锁流程——第一步按 Home// 唤醒屏幕;若其实是通知中心(WDA 误报),Home 会收起它,随后核对为未锁屏,一位都不输。- // 其余情况先核对,不动等待设置:不能自动解锁时免得把通知中心报成「需要人工解锁」,WDA 说没锁时确认一次就可信了+ // 其余情况先核对,不动等待设置:不能自动解锁时免得把通知中心报成「需要人工解锁」,WDA 说没锁时确认一次就可信了。+ // 核对也拿不准(锁屏样式的界面,WDA 说没锁)时:能自动解锁就进解锁流程,理由同上;不能就按没锁处理if !(reported && code.is_ok()) {match wda.check_lock(Some(reported), false).await {- Ok(c) if !c.locked => return Ok(Outcome::NotLocked),+ Ok(c) if !c.locked && !(c.uncertain && code.is_ok()) => return Ok(Outcome::NotLocked),Ok(_) => {}Err(WdaError::Unavailable(_)) => return Ok(Outcome::NotLocked),Err(e) => return Err(e.into()),}}let code = code?;- let saved = wda.idle_settings().await?;- // 上次异常退出没恢复的话,读到的就是解锁用的值:恢复成 WDA 默认值- let restore = if saved == UNLOCK_IDLE { WDA_DEFAULT_IDLE } else { saved };- wda.set_idle_settings(UNLOCK_IDLE).await?;+ // 解锁期间等待上限调小(不能是 0:唤醒会失败),做完恢复成平时的值。+ // 上次异常退出没恢复的话读到的是调小的值,baseline 会按 WDA 默认值算+ let restore = wda.baseline().await?;+ wda.set_idle_settings(IdleSettings::QUICK).await?;let r = unlock(wda, cfg, code.as_bytes()).await;if let Err(e) = wda.set_idle_settings(restore).await {tracing::warn!("恢复 WDA 等待设置失败:{e}");@@ -234,7 +231,8 @@ async fn unlock<T: Transport>(wda: &mut WdaClient<T>, cfg: &UnlockConfig, code:};tokio::time::sleep(t.swipe_settle).await;let check = wda.check_lock(None, false).await?;- if !check.locked {+ // 按过 Home、上滑之后还是认不出的锁屏样式界面:不算解开,接着找键盘(找不到就重来一轮)+ if !check.locked && !check.uncertain {return Ok(Outcome::Unlocked);}// 核对时已取到元素树就直接用,密码栏也从树里读。那棵树是上滑后马上取的,键盘有时还没进树:@@ -500,6 +498,35 @@ mod tests {std::fs::remove_dir_all(dir).unwrap();}+ /// iPad mini 5 真机:WDA 在锁屏时启动(一直报没锁),熄屏、有通知的锁屏上又没有锁的标记,认不出是锁屏。+ /// 以前会因此认定 WDA 可信、永远不自动解锁;现在能自动解锁就进解锁流程+ #[tokio::test]+ async fn unmarked_ipad_lock_screen_with_stale_wda_is_unlocked() {+ let fake = FakeLockScreen::ipad_lock_screen_without_hint("123456", "LANDSCAPE");+ fake.stale_wda_lock();+ let (cfg, dir) = cfg(Some("123456"));+ let mut wda = WdaClient::new(&fake);+ assert_eq!(ensure_unlocked(&mut wda, &cfg).await.unwrap(), Outcome::Unlocked);+ let s = fake.state();+ assert_eq!((s.locked, s.failed_attempts, s.digits_typed), (false, 0, 6));+ // 解开后在主屏上确认过,之后 WDA 说没锁就直接信+ assert!(wda.lock_state_trusted());+ std::fs::remove_dir_all(dir).unwrap();+ }++ /// 同上但没配密码:拿不准时按没锁处理,不报「需要人工解锁」(可能只是通知中心),也不认定 WDA 可信+ #[tokio::test]+ async fn unmarked_lock_screen_without_passcode_is_not_reported_locked() {+ let fake = FakeLockScreen::ipad_lock_screen_without_hint("123456", "LANDSCAPE");+ fake.stale_wda_lock();+ let (cfg, dir) = cfg(None);+ let mut wda = WdaClient::new(&fake);+ assert_eq!(ensure_unlocked(&mut wda, &cfg).await.unwrap(), Outcome::NotLocked);+ assert!(!wda.lock_state_trusted());+ assert_eq!(fake.state().digits_typed, 0);+ std::fs::remove_dir_all(dir).unwrap();+ }+/// 另一个横屏方向(Home 键在左):WDA 照样报 `LANDSCAPE`,按状态栏的位置换算,按对键#[tokio::test]async fn ipad_touch_id_landscape_home_left_unlocks() {@@ -603,13 +630,16 @@ mod tests {/// 上次异常退出没恢复等待设置:恢复成 WDA 默认值,而不是把解锁用的值当成原值#[tokio::test]async fn stuck_unlock_idle_settings_are_restored_to_defaults() {- let fake = FakeLockScreen::new("123456");- let (cfg, dir) = cfg(Some("123456"));- let mut wda = WdaClient::new(&fake);- wda.set_idle_settings(UNLOCK_IDLE).await.unwrap();- assert_eq!(ensure_unlocked(&mut wda, &cfg).await.unwrap(), Outcome::Unlocked);- assert_eq!(fake.state().idle, (10.0, 2.0));- std::fs::remove_dir_all(dir).unwrap();+ // 解锁用的值,或轮询、滑动用的值(之前漏判了这个)+ for stuck in [IdleSettings::QUICK, IdleSettings::NO_COOL_OFF] {+ let fake = FakeLockScreen::new("123456");+ let (cfg, dir) = cfg(Some("123456"));+ let mut wda = WdaClient::new(&fake);+ wda.set_idle_settings(stuck).await.unwrap();+ assert_eq!(ensure_unlocked(&mut wda, &cfg).await.unwrap(), Outcome::Unlocked);+ assert_eq!(fake.state().idle, (10.0, 2.0), "{stuck:?}");+ std::fs::remove_dir_all(dir).unwrap();+ }}#[tokio::test]diff --git a/crates/ictl-wda/src/client.rs b/crates/ictl-wda/src/client.rsindex a81e3c2..04bb15f 100644--- a/crates/ictl-wda/src/client.rs+++ b/crates/ictl-wda/src/client.rs@@ -70,7 +70,8 @@ impl IdleSettings {pub const NO_COOL_OFF: Self = Self { wait_for_idle_timeout: 1.0, animation_cool_off_timeout: 0.0 };}-const SPRINGBOARD: &str = "com.apple.springboard";+/// 主屏、锁屏、系统弹窗所属的进程+pub const SPRINGBOARD: &str = "com.apple.springboard";/// IOHID 消费者页(Consumer)const HID_PAGE_CONSUMER: u32 = 0x0C;/// 消费者页里的电源键@@ -95,6 +96,9 @@ pub enum Launch {#[derive(Debug)]pub struct LockCheck {pub locked: bool,+ /// 拿不准:WDA 说没锁,屏幕上却是锁屏样式的界面,认不出是锁屏还是通知中心(见 [`WdaClient::check_lock`])。+ /// `locked` 这时为 false;能自动解锁的调用方应当按可能锁着处理+ pub uncertain: bool,/// 核对时取到的 SpringBoard 元素树(没核对或前台不是 SpringBoard 时为 None)pub tree: Option<String>,}@@ -119,6 +123,7 @@ impl<T: Transport> WdaClient<T> {let body = body.map(|b| b.to_string().into_bytes());let (status, raw) = self.transport.send(method, path, body, timeout).await.map_err(|e| match e.kind() {std::io::ErrorKind::TimedOut => WdaError::Timeout(e.to_string()),+ crate::http::AFTER_SENT => WdaError::Interrupted(e.to_string()),_ => WdaError::Unavailable(e.to_string()),})?;let v: Value = match serde_json::from_slice(&raw) {@@ -126,7 +131,7 @@ impl<T: Transport> WdaClient<T> {Err(_) if status >= 400 => {return Err(WdaError::Remote { kind: "http".into(), message: status.to_string() });}- Err(e) => return Err(WdaError::Unavailable(format!("响应不是 JSON:{e}"))),+ Err(e) => return Err(WdaError::Interrupted(format!("响应不是 JSON:{e}"))),};if let Some(err) = v.get("value").and_then(|x| x.get("error")).and_then(|e| e.as_str()) {let msg = v["value"].get("message").and_then(|m| m.as_str()).unwrap_or_default();@@ -253,28 +258,34 @@ impl<T: Transport> WdaClient<T> {};if self.lock_state_trusted && (!wda_locked || strict) {// 已同步过:WDA 说没锁就是没锁;strict 场景在密码键盘上,WDA 说锁了也不会是通知中心- return Ok(LockCheck { locked: wda_locked, tree: None });+ return Ok(LockCheck { locked: wda_locked, uncertain: false, tree: None });}let (sheet, tree) = match self.cover_tree().await {Ok(x) => x,Err(e) => {tracing::debug!("核对锁屏界面失败,按{}处理:{e}", if strict { "锁着" } else { " WDA 的结果" });- return Ok(LockCheck { locked: strict || wda_locked, tree: None });+ return Ok(LockCheck { locked: strict || wda_locked, uncertain: false, tree: None });}};- let locked = match (wda_locked, sheet) {- (true, elements::CoverSheet::NotificationCenter) => false,- (true, _) => true,+ let (locked, uncertain) = match (wda_locked, sheet) {+ (true, elements::CoverSheet::NotificationCenter) => (false, false),+ (true, _) => (true, false),(false, elements::CoverSheet::Locked) => {tracing::info!("WDA 报未锁屏,但屏幕上是锁屏界面(WDA 在锁屏时启动,状态未同步)");- true+ (true, false)}- (false, _) => {+ // 锁屏样式、却没有锁的标记:可能是通知中心,也可能是 Touch ID 机型熄屏、有通知时的锁屏+ // (iPad mini 5 / iPadOS 26.6.1 真机:没有「按下主屏幕按钮以解锁」那行)。WDA 在锁屏时启动的话一直报 false,+ // 不能在这里认定它可信,否则之后再也不核对、永远不会自动解锁+ // 严格核对时拿不准就算锁着(同 `strict` 的说明)+ (false, elements::CoverSheet::NotificationCenter) => (strict, !strict),+ // 普通界面上确认过一次:WDA 的状态是同步的+ (false, elements::CoverSheet::None) => {self.lock_state_trusted = true;- false+ (false, false)}};- Ok(LockCheck { locked, tree })+ Ok(LockCheck { locked, uncertain, tree })}/// WDA 自己报的锁屏状态,不核对。可能误报,见 [`Self::locked`];配合 [`Self::lock_state_trusted`] 做快速判断@@ -364,8 +375,8 @@ impl<T: Transport> WdaClient<T> {}}- /// 平时的等待设置(第一次用时读一次)- async fn baseline(&mut self) -> Result<IdleSettings> {+ /// 平时的等待设置(第一次用时读一次)。临时调小、改回之前都按它恢复+ pub async fn baseline(&mut self) -> Result<IdleSettings> {if let Some(b) = self.idle_baseline {return Ok(b);}@@ -693,6 +704,24 @@ mod tests {assert!(matches!(c.active_app().await, Err(WdaError::Unavailable(_))));}+ /// 传输层报的错误按「请求送没送到」分类:只有没送到的才是 Unavailable(调用方会退到 HID 重做)+ #[tokio::test]+ async fn errors_after_sending_are_not_unavailable() {+ struct Fails(std::io::ErrorKind);+ impl Transport for Fails {+ async fn send(&self, _: &str, _: &str, _: Option<Vec<u8>>, _: Duration) -> std::io::Result<(u16, Vec<u8>)> {+ Err(std::io::Error::new(self.0, "x"))+ }+ }+ let kind = |k| async move { WdaClient::new(Fails(k)).active_app().await };+ assert!(matches!(kind(crate::http::AFTER_SENT).await, Err(WdaError::Interrupted(_))));+ assert!(matches!(kind(std::io::ErrorKind::TimedOut).await, Err(WdaError::Timeout(_))));+ assert!(matches!(kind(std::io::ErrorKind::NotConnected).await, Err(WdaError::Unavailable(_))));+ // 应答了但不是 JSON:WDA 收到了请求+ let m = Mock::with(&[(200, "<html>")]);+ assert!(matches!(WdaClient::new(&m).active_app().await, Err(WdaError::Interrupted(_))));+ }+#[tokio::test]async fn screen_size_is_cached_and_status_ready() {let unknown = r#"{"value":{"error":"unknown command","message":"no"}}"#;diff --git a/crates/ictl-wda/src/elements.rs b/crates/ictl-wda/src/elements.rsindex dbc9992..199f5a4 100644--- a/crates/ictl-wda/src/elements.rs+++ b/crates/ictl-wda/src/elements.rs@@ -29,6 +29,14 @@ impl Rect {fn contains(&self, (px, py): (f64, f64)) -> bool {px >= self.x && px < self.x + self.w && py >= self.y && py < self.y + self.h}++ /// 整个盖住 `o`(各边容差 1 点)+ fn covers(&self, o: &Rect) -> bool {+ self.x <= o.x + 1.0+ && self.y <= o.y + 1.0+ && self.x + self.w >= o.x + o.w - 1.0+ && self.y + self.h >= o.y + o.h - 1.0+ }}/// 界面方向,来自 WDA 的 `GET /session/:id/orientation`@@ -156,6 +164,8 @@ pub struct Element {layer: Layer,/// 最近的栏、键盘、弹窗、面板祖先(含自己)的序号;0 = 没有。同一个栏/弹窗里的东西互相不算盖住group: usize,+ /// 所在的可滚动区域(屏幕坐标);不在可滚动内容里时为 None+ scroller: Option<Rect>,}/// 元素所在的层@@ -170,17 +180,9 @@ enum Layer {Bar,}-/// 只比看得见的内容:等界面稳定时比较前后两棵树,不因没有文字的节点增减而算「变了」-impl PartialEq for Element {- fn eq(&self, o: &Self) -> bool {- (&self.kind, &self.label, &self.name, &self.value, self.center, self.size)- == (&o.kind, &o.label, &o.name, &o.value, o.center, o.size)- }-}-/// 可能盖住别的元素的东西,包括没有文字的容器(例如悬浮搜索栏的底板、键盘)。/// 可滚动内容里的节点不算(单元格的背景层、滚到导航栏底下的行)-#[derive(Debug, Clone, PartialEq)]+#[derive(Debug, Clone)]struct Blocker {span: (usize, usize),rect: Rect,@@ -203,12 +205,6 @@ pub struct Tree {pub loading: bool,}-impl PartialEq for Tree {- fn eq(&self, o: &Self) -> bool {- self.elements == o.elements && self.loading == o.loading- }-}-/// 按名字点击时实际点哪里#[derive(Debug, Clone, PartialEq)]pub enum TapPoint {@@ -255,14 +251,15 @@ impl Tree {/// 点 `e` 时落在哪。WDA 不给可见性(太慢),只能按位置推:树里在它后面出现、又不是它后代、并且能盖住它的东西/// 画在它上面。单靠树里的先后会误判(单元格里的背景层排在按钮后面;导航栏排在滚到它底下的内容前面),所以按层限定:/// - 栏里的元素只会被键盘、弹窗、面板盖住- /// - 可滚动内容里的元素会被内容外面的任何东西盖住(悬浮栏、浮层横幅)+ /// - 可滚动内容里的元素会被内容外面的任何东西盖住(悬浮栏、浮层横幅),但和整个滚动区一样大或更大的非模态层不算:+ /// 那是滚动区的背景、边缘效果(iPadOS 26 浮动侧栏的列表后面跟着几层和侧栏一样大的空容器),不是盖在上面的东西/// - 其他元素只会被浮在上面的层(工具栏、标签栏、键盘、弹窗、面板)盖住pub fn tap_point(&self, e: &Element) -> TapPoint {let can_cover = |b: &Blocker| {(e.group == 0 || b.group != e.group)&& match e.layer {Layer::Bar => b.modal,- Layer::Scroll => true,+ Layer::Scroll => b.modal || !e.scroller.is_some_and(|s| b.rect.covers(&s)),Layer::Plain => b.floating,}};@@ -367,6 +364,8 @@ struct Open {on_bar: bool,/// 在可滚动的内容里in_scroll: bool,+ /// 自己是滚动区就是自己,否则同父节点(屏幕坐标)+ scroller: Option<Rect>,/// 在键盘、弹窗、面板里modal: bool,group: usize,@@ -499,6 +498,7 @@ pub fn parse_tree(xml: &str, view: impl Into<View>) -> Tree {}}+ let scroller = if SCROLLERS.contains(&kind.as_str()) { Some(visible) } else { parent.and_then(|p| p.scroller) };let kind_for_children = kind.clone();let kept = text.filter(|text| {let noise = !onscreen@@ -536,6 +536,7 @@ pub fn parse_tree(xml: &str, view: impl Into<View>) -> Tree {Layer::Plain},group,+ scroller: parent.and_then(|p| p.scroller),});tree.elements.len() - 1});@@ -544,6 +545,7 @@ pub fn parse_tree(xml: &str, view: impl Into<View>) -> Tree {in_bar,on_bar,in_scroll,+ scroller,modal,group,kind: kind_for_children,@@ -885,6 +887,18 @@ mod tests {assert!(matches!(t.tap_point(cancel), TapPoint::Center(_)));}+ /// iPad mini 5 / iPadOS 26.6.1 横屏的设置:浮动侧栏的列表后面跟着几层和侧栏一样大、没有文字的容器。+ /// 它们不是盖在列表上的东西,侧栏里的「通用」要点得到+ #[test]+ fn ipad_floating_sidebar_rows_are_not_covered_by_sidebar_backdrop() {+ let xml = include_str!("../tests/fixtures/ipad-settings-sidebar-landscape.xml");+ let tree = parse_tree(xml, IPAD_LAND);+ for text in ["通用", "电池", "辅助功能", "关于本机"] {+ let e = find(&tree.elements, text)[0];+ assert!(matches!(tree.tap_point(e), TapPoint::Center(_)), "{text}: {:?}", tree.tap_point(e));+ }+ }+#[test]fn tap_point_reports_fully_covered() {let xml = r#"<XCUIElementTypeApplication type="XCUIElementTypeApplication" x="0" y="0" width="430" height="932">diff --git a/crates/ictl-wda/src/http.rs b/crates/ictl-wda/src/http.rsindex fb6c6d6..f01fe18 100644--- a/crates/ictl-wda/src/http.rs+++ b/crates/ictl-wda/src/http.rs@@ -11,7 +11,11 @@ use std::time::Duration;use idevice::provider::IdeviceProvider;use tokio::io::{AsyncReadExt, AsyncWriteExt};-/// 一次 HTTP 请求的传输。抽象出来便于单测里换成假的+/// 一次 HTTP 请求的传输。抽象出来便于单测里换成假的。+///+/// 错误的 kind 区分请求有没有送到 WDA(决定能不能退到 HID 重做):+/// [`ErrorKind::TimedOut`](std::io::ErrorKind::TimedOut) 是发出后没在时限内应答,+/// [`AFTER_SENT`] 是发出后连接断了或响应不完整、看不懂;其他 kind 都表示请求没送到pub trait Transport: Send + Sync {fn send(&self,@@ -39,6 +43,13 @@ impl DeviceTransport {/// 连上之后的超时是「请求已发出、手机可能还在执行」,不能退到 HID 重做一遍const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);+/// 请求已经整个发出、之后读响应出错的 kind:WDA 可能已经执行了这个操作+pub const AFTER_SENT: std::io::ErrorKind = std::io::ErrorKind::ConnectionAborted;++fn after_sent(e: std::io::Error) -> std::io::Error {+ std::io::Error::new(AFTER_SENT, e.to_string())+}+impl Transport for DeviceTransport {async fn send(&self,@@ -57,8 +68,10 @@ impl Transport for DeviceTransport {.get_socket().ok_or_else(|| std::io::Error::new(std::io::ErrorKind::NotConnected, "连接没有套接字"))?;let fut = async {- sock.write_all(&req).await?;- sock.flush().await?;+ // 没写完 WDA 不会处理(HTTP 请求不完整),算没送到+ let not_sent = |e: std::io::Error| std::io::Error::new(std::io::ErrorKind::NotConnected, e.to_string());+ sock.write_all(&req).await.map_err(not_sent)?;+ sock.flush().await.map_err(not_sent)?;// WDA 收到 `Connection: close` 也不关连接,不能读到 EOF:读够一个完整响应就停。// 头部只解析一次;正文按 Content-Length 判断,chunked 只在收到结束块后才完整解一次let mut buf = Vec::new();@@ -76,13 +89,13 @@ impl Transport for DeviceTransport {{break;}- let n = sock.read(&mut chunk).await?;+ let n = sock.read(&mut chunk).await.map_err(after_sent)?;if n == 0 {break;}buf.extend_from_slice(&chunk[..n]);}- parse_response(buf)+ parse_response(buf).map_err(after_sent)};let r = tokio::time::timeout(timeout, fut).await.map_err(|_| {std::io::Error::new(std::io::ErrorKind::TimedOut, format!("请求超时({} 秒)", timeout.as_secs()))diff --git a/crates/ictl-wda/src/lib.rs b/crates/ictl-wda/src/lib.rsindex f4abb07..7776ea8 100644--- a/crates/ictl-wda/src/lib.rs+++ b/crates/ictl-wda/src/lib.rs@@ -9,8 +9,7 @@ pub mod elements;pub mod http;pub mod runner;-pub use client::{IdleSettings, Launch, LockCheck, PointerStep, WdaClient, actions_body, swipe_steps, tap_steps};-pub use elements::{Element, Orientation, View};+pub use client::{IdleSettings, Launch, WdaClient, swipe_steps, tap_steps};pub use runner::WdaRunner;#[derive(Debug, thiserror::Error)]@@ -21,6 +20,9 @@ pub enum WdaError {/// 请求已经发出但没在时限内应答:手机可能还在执行,不能退到 HID 再做一遍#[error("WDA 请求超时(请求已发出,手机可能仍在执行,先截图确认):{0}")]Timeout(String),+ /// 请求已经发出,之后连接断了或响应不完整:手机可能已经执行,同样不能退到 HID 再做一遍+ #[error("WDA 在请求发出后断开(手机可能已经执行,先截图确认):{0}")]+ Interrupted(String),/// 手机重启后首次启用 UI 自动化,需要用户在手机上输入锁屏密码#[error("WDA 卡在「Enable UI Automation」密码框,请在手机上输入锁屏密码")]NeedsAutomationPin,diff --git a/crates/ictl-wda/src/runner.rs b/crates/ictl-wda/src/runner.rsindex 2ad4829..c293f3a 100644--- a/crates/ictl-wda/src/runner.rs+++ b/crates/ictl-wda/src/runner.rs@@ -2,6 +2,7 @@//!//! 用 idevice 的 `XCUITestService` 跑测试计划;它自己经 usbmuxd 建 CoreDeviceProxy 隧道,和设备层的隧道互不影响。//! 就绪判定 = 本进程持有的 runner 任务还活着 **且** `/status` ready(手机上残留的 WDA 在 runner 退出后还会响应几十秒)。+//! 启动时还要等新 runner 开始执行测试计划后才问 `/status`:在那之前应答的只可能是残留的旧 WDA。use std::sync::{Arc, Mutex};use std::time::Duration;@@ -21,6 +22,11 @@ pub const WDA_PORT: u16 = 8100;/// runner 等「Enable UI Automation」密码的时长是 60 秒(runner 自己的超时),多留 5 秒收它的报错const AUTOMATION_WAIT: Duration = Duration::from_secs(65);+/// 连接 installation_proxy、查 runner 的安装信息的时限(idevice 读应答没有超时)+const LOOKUP_TIMEOUT: Duration = Duration::from_secs(20);+/// 一直没收到「开始执行测试计划」回调时,过了这么久也开始问 `/status`:+/// 万一某个 iOS 版本上 idevice 解不出这个回调,不能因此永远起不来+const PLAN_START_FALLBACK: Duration = Duration::from_secs(30);/// runner 调试日志里和「Enable UI Automation」相关的信号。/// 手机重启后 runner 一启动就进入 `enabling automation mode` 等待(手机上弹密码框),60 秒没输密码报@@ -66,6 +72,8 @@ fn launch_hint(msg: String) -> String {struct Progress {errors: Vec<String>,automation_wait: Option<tokio::time::Instant>,+ /// 新 runner 已开始执行测试计划(WDA 的 HTTP 服务在测试里启动,一定晚于它)+ plan_started: bool,}struct ErrorListener(Arc<Mutex<Progress>>);@@ -112,6 +120,7 @@ impl XCUITestListener for ErrorListener {async fn did_begin_executing_test_plan(&mut self) -> std::result::Result<(), IdeviceError> {tracing::debug!("xctest: 开始执行测试计划");+ self.0.lock().unwrap().plan_started = true;Ok(())}@@ -130,7 +139,6 @@ impl XCUITestListener for ErrorListener {}pub struct WdaRunner {- pub bundle_id: String,task: JoinHandle<std::result::Result<(), IdeviceError>>,}@@ -141,12 +149,17 @@ impl WdaRunner {bundle_id: &str,timeout: Duration,) -> Result<(Self, WdaClient<DeviceTransport>)> {- let mut ip =- InstallationProxyClient::connect(&*provider).await.map_err(|e| WdaError::Unavailable(e.to_string()))?;- let cfg = TestConfig::from_installation_proxy(&mut ip, bundle_id, None).await.map_err(|e| match e {- IdeviceError::AppNotInstalled => WdaError::NotInstalled(bundle_id.to_owned()),- other => WdaError::StartFailed(other.to_string()),- })?;+ let lookup = async {+ let mut ip =+ InstallationProxyClient::connect(&*provider).await.map_err(|e| WdaError::Unavailable(e.to_string()))?;+ TestConfig::from_installation_proxy(&mut ip, bundle_id, None).await.map_err(|e| match e {+ IdeviceError::AppNotInstalled => WdaError::NotInstalled(bundle_id.to_owned()),+ other => WdaError::StartFailed(other.to_string()),+ })+ };+ let cfg = tokio::time::timeout(LOOKUP_TIMEOUT, lookup)+ .await+ .map_err(|_| WdaError::StartFailed(format!("查 WDA 安装信息超时({} 秒)", LOOKUP_TIMEOUT.as_secs())))??;let progress = Arc::new(Mutex::new(Progress::default()));let task = {@@ -155,7 +168,7 @@ impl WdaRunner {async move { XCUITestService::new(provider).run(cfg, &mut ErrorListener(progress), None).await },)};- let mut runner = Self { bundle_id: bundle_id.to_owned(), task };+ let mut runner = Self { task };let client = WdaClient::new(DeviceTransport::new(provider, WDA_PORT));let failure = |extra: Option<String>| {@@ -171,8 +184,10 @@ impl WdaRunner {}};- let mut deadline = tokio::time::Instant::now() + timeout;+ let t0 = tokio::time::Instant::now();+ let mut deadline = t0 + timeout;let mut announced = false;+ let mut fallback_logged = false;loop {// runner 在等手机上输密码:等满它自己的 60 秒,期间输了密码就能直接就绪if let Some(since) = progress.lock().unwrap().automation_wait {@@ -191,7 +206,15 @@ impl WdaRunner {};return Err(failure(Some(msg)));}- if client.ready().await.unwrap_or(false) {+ let plan_started = progress.lock().unwrap().plan_started;+ if !plan_started && t0.elapsed() >= PLAN_START_FALLBACK && !fallback_logged {+ fallback_logged = true;+ tracing::info!(+ "{} 秒内没收到 runner 开始执行测试计划的回调,改为直接查 /status",+ PLAN_START_FALLBACK.as_secs()+ );+ }+ if (plan_started || fallback_logged) && client.ready().await.unwrap_or(false) {return Ok((runner, client));}if tokio::time::Instant::now() >= deadline {diff --git a/crates/ictl-wda/tests/fixtures/ipad-settings-sidebar-landscape.xml b/crates/ictl-wda/tests/fixtures/ipad-settings-sidebar-landscape.xmlnew file mode 100644index 0000000..e9d464e--- /dev/null+++ b/crates/ictl-wda/tests/fixtures/ipad-settings-sidebar-landscape.xml@@ -0,0 +1,583 @@+<?xml version="1.0" encoding="UTF-8"?>+<XCUIElementTypeApplication type="XCUIElementTypeApplication" name="设置" label="设置" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="" processId="809" bundleId="com.apple.Preferences">+ <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="设置" enabled="true" x="10" y="32" width="320" height="108" index="0" traits="">+ <XCUIElementTypeSearchField type="XCUIElementTypeSearchField" value="搜索" name="搜索" label="搜索" enabled="true" x="26" y="87" width="288" height="38" index="0" placeholderValue="搜索" traits="SearchField">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Dictate" label="听写" enabled="true" x="284" y="95" width="14" height="22" index="0" traits="Button"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" name="magnifyingglass" label="搜索" enabled="true" x="38" y="98" width="17" height="16" index="1" traits="Image"/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Dictate" label="听写" enabled="true" x="284" y="95" width="14" height="22" index="2" traits="Button"/>+ </XCUIElementTypeSearchField>+ </XCUIElementTypeNavigationBar>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeCollectionView type="XCUIElementTypeCollectionView" name="边栏" label="边栏" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-6" y="-1312" width="352" height="1649" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="158" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="2" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="140" width="288" height="82" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="140" width="288" height="82" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="140" width="288" height="82" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="140" width="288" height="82" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="140" width="288" height="82" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.primaryAppleAccount" label="示例用户、Apple账户、iCloud+等" enabled="true" x="26" y="140" width="288" height="82" index="0" traits="StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="42" y="151" width="60" height="60" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="示例用户" name="示例用户" label="示例用户" enabled="true" x="110" y="162" width="51" height="21" index="1" traits="StaticText"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Apple账户、iCloud+等" name="Apple账户、iCloud+等" label="Apple账户、iCloud+等" enabled="true" x="110" y="185" width="126" height="15" index="2" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="222" width="288" height="55" index="4" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="222" width="288" height="55" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="222" width="288" height="55" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="222" width="288" height="55" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="222" width="288" height="55" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.family" label="家人共享" enabled="true" x="26" y="222" width="288" height="55" index="0" traits="StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="42" y="233" width="60" height="33" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="家人共享" name="家人共享" label="家人共享" enabled="true" x="110" y="241" width="56" height="17" index="1" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="277" width="288" height="50" index="5" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="277" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="277" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="277" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="277" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.followUpGroupAsItem.com.apple.followup.group.services.2DE4EEAD-A7DA-4D59-B596-0FC670BB47CC" label="Apple TV+ Free for 3 Months" enabled="true" x="26" y="277" width="288" height="50" index="0" traits="StaticText, Button"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-6" y="336" width="352" height="258" index="6" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="336" width="288" height="50" index="7" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="336" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="336" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="336" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="336" width="288" height="50" index="0" traits="">+ <XCUIElementTypeSwitch type="XCUIElementTypeSwitch" value="0" name="com.apple.settings.airplaneMode" label="飞行模式" enabled="true" x="26" y="336" width="288" height="50" index="0" traits="ToggleButton, StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="飞行模式" name="飞行模式" label="飞行模式" enabled="true" x="72" y="352" width="57" height="18" index="0" traits="StaticText"/>+ <XCUIElementTypeSwitch type="XCUIElementTypeSwitch" value="0" enabled="true" x="237" y="347" width="63" height="29" index="1" traits="ToggleButton, Button"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="347" width="29" height="29" index="2" traits="Image"/>+ </XCUIElementTypeSwitch>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="386" width="288" height="50" index="8" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="386" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="386" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="386" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="386" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.wifi" label="无线局域网、Home-WiFi" enabled="true" x="26" y="386" width="288" height="50" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="无线局域网" name="无线局域网" label="无线局域网" enabled="true" x="38" y="396" width="260" height="30" index="0" traits="StaticText"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Home-WiFi" name="Home-WiFi" label="Home-WiFi" enabled="true" x="224" y="402" width="74" height="18" index="1" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="396" width="29" height="30" index="2" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="435" width="288" height="50" index="9" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="435" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="435" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="435" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="435" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.bluetooth" label="蓝牙、打开" enabled="true" x="26" y="435" width="288" height="50" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="蓝牙" name="蓝牙" label="蓝牙" enabled="true" x="38" y="446" width="260" height="29" index="0" traits="StaticText"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="打开" name="打开" label="打开" enabled="true" x="270" y="451" width="28" height="18" index="1" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="446" width="29" height="29" index="2" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="485" width="288" height="50" index="10" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="485" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="485" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="485" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="485" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.battery" label="电池" enabled="true" x="26" y="485" width="288" height="50" index="0" traits="StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="495" width="29" height="30" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="电池" name="电池" label="电池" enabled="true" x="38" y="495" width="63" height="30" index="1" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="534" width="288" height="50" index="11" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="534" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="534" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="534" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="534" width="288" height="50" index="0" traits="">+ <XCUIElementTypeSwitch type="XCUIElementTypeSwitch" value="0" name="com.apple.settings.vpn" label="VPN" enabled="true" x="26" y="534" width="288" height="50" index="0" traits="ToggleButton, StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="VPN" name="VPN" label="VPN" enabled="true" x="72" y="550" width="29" height="18" index="0" traits="StaticText"/>+ <XCUIElementTypeSwitch type="XCUIElementTypeSwitch" value="0" enabled="true" x="237" y="545" width="63" height="29" index="1" traits="ToggleButton, Button"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="545" width="29" height="29" index="2" traits="Image"/>+ </XCUIElementTypeSwitch>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-6" y="594" width="352" height="553" index="12" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="594" width="288" height="50" index="13" traits="Selected">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="594" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="594" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="594" width="288" height="50" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="594" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="594" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="594" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" value="1" name="com.apple.settings.general" label="通用" enabled="true" x="26" y="594" width="288" height="50" index="0" traits="Selected, StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="604" width="29" height="30" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="通用" name="通用" label="通用" enabled="true" x="38" y="604" width="63" height="30" index="1" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="643" width="288" height="50" index="14" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="643" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="643" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="643" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="643" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.accessibility" label="辅助功能" enabled="true" x="26" y="643" width="288" height="50" index="0" traits="StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="654" width="29" height="29" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="辅助功能" name="辅助功能" label="辅助功能" enabled="true" x="38" y="654" width="91" height="29" index="1" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="693" width="288" height="50" index="15" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="693" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="693" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="693" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="693" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.multitaskingAndGestures" label="多任务与手势" enabled="true" x="26" y="693" width="288" height="50" index="0" traits="StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="703" width="29" height="30" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="多任务与手势" name="多任务与手势" label="多任务与手势" enabled="true" x="38" y="703" width="118" height="30" index="1" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="26" y="742" width="288" height="50" index="16" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="742" width="288" height="50" index="0" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="742" width="288" height="50" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="742" width="288" height="50" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="26" y="742" width="288" height="50" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="com.apple.settings.controlCenter" label="控制中心" enabled="true" x="26" y="742" width="288" height="50" index="0" traits="StaticText, Button">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="38" y="753" width="29" height="29" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="控制中心" name="控制中心" label="控制中心" enabled="true" x="38" y="753" width="91" height="29" index="1" traits="StaticText"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0%" name="垂直滚动条, 3页" label="垂直滚动条, 3页" enabled="true" x="297" y="140" width="30" height="596" index="17" traits="Adjustable">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="324" y="143" width="3" height="276" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0%" name="垂直滚动条, 3页" label="垂直滚动条, 3页" enabled="true" x="297" y="140" width="30" height="596" index="18" traits="Adjustable">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="324" y="143" width="3" height="276" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeCollectionView>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="170" y="449" width="0" height="0" index="1" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="2" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="10" y="32" width="320" height="726" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="通用" enabled="true" x="0" y="32" width="1024" height="54" index="0" traits="">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="通用" name="通用" label="通用" enabled="true" x="665" y="43" width="34" height="22" index="0" traits="Header"/>+ </XCUIElementTypeNavigationBar>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="330" y="86" width="694" height="682" index="0" traits="">+ <XCUIElementTypeTable type="XCUIElementTypeTable" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="1024" height="18" index="0" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="PLACARD" enabled="true" x="346" y="103" width="662" height="160" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="103" width="662" height="160" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="103" width="662" height="160" index="0" traits="">+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="366" y="119" width="60" height="60" index="0" traits="Image"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="通用" name="通用" label="通用" enabled="true" x="366" y="199" width="38" height="23" index="1" traits="Header, StaticText"/>+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="管理iPad的整体设置和偏好设置,例如软件更新、设备语言、隔空投送等。" name="管理iPad的整体设置和偏好设置,例如软件更新、设备语言、隔空投送等。" label="管理iPad的整体设置和偏好设置,例如软件更新、设备语言、隔空投送等。" enabled="true" x="366" y="230" width="456" height="17" index="2" traits="Header, StaticText"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="103" width="662" height="160" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="103" width="662" height="160" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="261" width="662" height="2" index="2" traits=""/>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="262" width="1024" height="18" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="280" width="1024" height="18" index="3" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="About" label="关于本机" enabled="true" x="346" y="297" width="662" height="51" index="4" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="297" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="297" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="About" label="关于本机" enabled="true" x="362" y="309" width="97" height="28" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="关于本机" name="关于本机" label="关于本机" enabled="true" x="362" y="309" width="97" height="28" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="309" width="29" height="28" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="297" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="297" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="402" y="347" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="316" width="9" height="13" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="SOFTWARE_UPDATE_LINK" label="软件更新" enabled="true" x="346" y="348" width="662" height="51" index="5" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="348" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="348" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="SOFTWARE_UPDATE_LINK" label="软件更新" enabled="true" x="362" y="359" width="97" height="29" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="软件更新" name="软件更新" label="软件更新" enabled="true" x="362" y="359" width="97" height="29" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="359" width="29" height="29" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="348" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="348" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="402" y="397" width="586" height="2" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="367" width="9" height="12" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="STORAGE_MGMT" label="iPad储存空间" enabled="true" x="346" y="398" width="662" height="51" index="6" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="398" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="398" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="STORAGE_MGMT" label="iPad储存空间" enabled="true" x="362" y="410" width="126" height="28" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="iPad储存空间" name="iPad储存空间" label="iPad储存空间" enabled="true" x="362" y="410" width="126" height="28" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="410" width="29" height="28" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="398" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="398" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="448" width="662" height="1" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="417" width="9" height="13" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="449" width="1024" height="18" index="7" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="466" width="1024" height="18" index="8" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="COVERAGE" label="AppleCare与保修" enabled="true" x="346" y="484" width="662" height="51" index="9" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="484" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="484" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="COVERAGE" label="AppleCare与保修" enabled="true" x="362" y="495" width="152" height="29" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="AppleCare与保修" name="AppleCare与保修" label="AppleCare与保修" enabled="true" x="362" y="495" width="152" height="29" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="495" width="29" height="29" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="484" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="484" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="533" width="662" height="2" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="503" width="9" height="12" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="534" width="1024" height="18" index="10" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="552" width="1024" height="18" index="11" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="AIRDROP_LINK" label="隔空投送" enabled="true" x="346" y="569" width="662" height="51" index="12" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="569" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="569" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="AIRDROP_LINK" label="隔空投送" enabled="true" x="362" y="581" width="97" height="28" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="隔空投送" name="隔空投送" label="隔空投送" enabled="true" x="362" y="581" width="97" height="28" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="581" width="29" height="28" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="569" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="569" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="402" y="619" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="588" width="9" height="13" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="CONTINUITY_SPEC" label="隔空播放与连续互通" enabled="true" x="346" y="620" width="662" height="51" index="13" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="620" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="620" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="CONTINUITY_SPEC" label="隔空播放与连续互通" enabled="true" x="362" y="631" width="166" height="29" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="隔空播放与连续互通" name="隔空播放与连续互通" label="隔空播放与连续互通" enabled="true" x="362" y="631" width="166" height="29" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="631" width="29" height="29" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="620" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="620" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="402" y="669" width="586" height="2" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="639" width="9" height="12" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="SCREEN_CAPTURE" label="屏幕捕捉" enabled="true" x="346" y="670" width="662" height="51" index="14" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="670" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="670" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="SCREEN_CAPTURE" label="屏幕捕捉" enabled="true" x="362" y="682" width="97" height="28" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="屏幕捕捉" name="屏幕捕捉" label="屏幕捕捉" enabled="true" x="362" y="682" width="97" height="28" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="682" width="29" height="28" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="670" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="670" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="720" width="662" height="1" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="689" width="9" height="13" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="721" width="1024" height="18" index="15" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="738" width="1024" height="18" index="16" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="DICTIONARY" label="词典" enabled="true" x="346" y="756" width="662" height="51" index="17" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="756" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="756" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="DICTIONARY" label="词典" enabled="true" x="362" y="767" width="69" height="29" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="词典" name="词典" label="词典" enabled="true" x="362" y="767" width="69" height="29" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="767" width="29" height="29" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="756" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="756" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="402" y="805" width="586" height="2" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="775" width="9" height="12" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="AUTO_CONTENT_DOWNLOAD" label="后台App刷新" enabled="true" x="346" y="806" width="662" height="51" index="18" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="806" width="634" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="806" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="AUTO_CONTENT_DOWNLOAD" label="后台App刷新" enabled="true" x="362" y="818" width="126" height="28" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="后台App刷新" name="后台App刷新" label="后台App刷新" enabled="true" x="362" y="818" width="126" height="28" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="362" y="818" width="29" height="28" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="806" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="346" y="806" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="402" y="856" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="979" y="825" width="9" height="13" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="Keyboard" label="键盘" enabled="true" x="346" y="857" width="662" height="51" index="19" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Keyboard" label="键盘" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="键盘" name="键盘" label="键盘" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="DATE_AND_TIME" label="日期与时间" enabled="true" x="346" y="907" width="662" height="51" index="20" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="DATE_AND_TIME" label="日期与时间" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="日期与时间" name="日期与时间" label="日期与时间" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="INTERNATIONAL" label="语言与地区" enabled="true" x="346" y="958" width="662" height="51" index="21" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="INTERNATIONAL" label="语言与地区" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="语言与地区" name="语言与地区" label="语言与地区" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="FONT_SETTING" label="字体" enabled="true" x="346" y="1008" width="662" height="51" index="22" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="586" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="FONT_SETTING" label="字体" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="字体" name="字体" label="字体" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="AUTOFILL" label="自动填充与密码" enabled="true" x="346" y="1059" width="662" height="51" index="23" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="AUTOFILL" label="自动填充与密码" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="自动填充与密码" name="自动填充与密码" label="自动填充与密码" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="756" width="1024" height="18" index="24" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1127" width="1024" height="18" index="25" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="TV_PROVIDER" label="电视提供商" enabled="true" x="346" y="1144" width="662" height="51" index="26" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="1" index="1" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="2" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="TV_PROVIDER" label="电视提供商" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="电视提供商" name="电视提供商" label="电视提供商" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="3" traits="NotEnabled, Button"/>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1144" width="1024" height="18" index="27" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1212" width="1024" height="18" index="28" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="ManagedConfigurationList" label="VPN与设备管理" enabled="true" x="346" y="1230" width="662" height="51" index="29" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="ManagedConfigurationList" label="VPN与设备管理" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="VPN与设备管理" name="VPN与设备管理" label="VPN与设备管理" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1230" width="1024" height="18" index="30" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1298" width="1024" height="18" index="31" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="LEGAL_AND_REGULATORY" label="法律与监管" enabled="true" x="346" y="1315" width="662" height="51" index="32" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="LEGAL_AND_REGULATORY" label="法律与监管" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="法律与监管" name="法律与监管" label="法律与监管" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1315" width="1024" height="18" index="33" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1383" width="1024" height="18" index="34" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="Reset" label="传输或还原iPad" enabled="true" x="346" y="1401" width="662" height="51" index="35" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="chevron" label="chevron" enabled="false" x="0" y="86" width="9" height="12" index="1" traits="NotEnabled, Button"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="1" index="2" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="3" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="634" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Reset" label="传输或还原iPad" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="传输或还原iPad" name="传输或还原iPad" label="传输或还原iPad" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText"/>+ <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="0" height="0" index="1" traits="Image"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1401" width="1024" height="18" index="36" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1469" width="1024" height="18" index="37" traits=""/>+ <XCUIElementTypeCell type="XCUIElementTypeCell" name="SHUTDOWN_LABEL" label="关机" enabled="true" x="346" y="1486" width="662" height="51" index="38" traits="Button">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="51" index="0" traits="">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="SHUTDOWN_LABEL" label="关机" enabled="true" x="0" y="0" width="0" height="0" index="0" traits="StaticText, Button"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="86" width="662" height="1" index="2" traits=""/>+ </XCUIElementTypeCell>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1486" width="1024" height="18" index="39" traits=""/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0%" name="垂直滚动条, 3页" label="垂直滚动条, 3页" enabled="true" x="991" y="86" width="30" height="682" index="40" traits="Adjustable">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="1018" y="89" width="3" height="352" index="0" traits=""/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0%" name="水平滚动条, 1页" label="水平滚动条, 1页" enabled="true" x="330" y="735" width="694" height="30" index="41" traits="Adjustable">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="333" y="762" width="685" height="3" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeTable>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="2" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeWindow>+ <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" x="0" y="0" width="1024" height="768" index="1" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits="">+ <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="1024" height="768" index="0" traits=""/>+ </XCUIElementTypeOther>+ </XCUIElementTypeWindow>+</XCUIElementTypeApplication>diff --git a/deploy/iphone-control.service b/deploy/iphone-control.serviceindex 5de6d70..678e9f0 100644--- a/deploy/iphone-control.service+++ b/deploy/iphone-control.service@@ -1,4 +1,4 @@-# 从源码运行时的 systemd 用户服务(不用 Docker)。安装见 README「从源码运行」。+# 从源码运行时的 systemd 用户服务(不用 Docker)。安装见 https://derrors.github.io/iphone-control/deploy/source# cp deploy/iphone-control.service ~/.config/systemd/user/# systemctl --user daemon-reload && systemctl --user enable --now iphone-control# loginctl enable-linger "$USER" # 不登录也随开机启动diff --git a/docker/Dockerfile b/docker/Dockerfileindex 95394e7..28758f7 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -31,7 +31,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \-o /THIRD_PARTY_LICENSES.html# ---- WebDriverAgent:Appium 官方构建的未签名真机包,重新打成 IPA -----# 计划改为本项目在 macOS CI 上自己编译(docs/dev/roadmap.md 阶段 7)+# 计划改为本项目在 macOS CI 上自己编译(docs/dev/archive/roadmap.md 阶段 7)FROM ${DEBIAN_IMAGE} AS wdaARG WDA_VERSION=v16.15.3ARG WDA_SHA256=2176793538d902f6b1e61291e9997f68d306541f222ea715d256a7c6ce9d4fc5diff --git a/docs/architecture.md b/docs/architecture.mdindex 94a373d..5e2d3b5 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -3,7 +3,7 @@## 1. 总览```-┌──────────────────────── Linux 主机 / 容器 ─────────────────────────────────────┐+┌──────────────────── Linux / macOS 主机或容器 ─────────────────────────────────┐│ ││ Claude Code ──stdio──▶ iphone-control mcp ──unix socket──┐ ││ (每个会话一个,短命) (ictl-mcp,经 ictl-protocol) │ │@@ -23,7 +23,7 @@└────────┼──────────────────────────────────────────────────────────────────────┘│ USB┌─────▼───────────────────────────────┐- │ iPhone(iOS 17+,开发者模式) │+ │ iPhone / iPad(iOS 17+,开发者模式) ││ 开发者镜像(Cryptex,iOS 27 含 dtuhidd)││ WebDriverAgent(免费 Apple ID 签名) │└─────────────────────────────────────┘@@ -35,12 +35,12 @@| 进程 | 生命周期 | 职责 ||---|---|---|-| `iphone-control daemon` | 常驻,容器入口(从源码运行时由 systemd 用户服务启动) | 唯一和设备通信的进程。维护设备状态机,对外提供本地控制接口 |+| `iphone-control daemon` | 常驻,容器入口(Linux 上从源码运行时由 systemd 用户服务启动;macOS 上在终端里前台运行) | 唯一和设备通信的进程。维护设备状态机,对外提供本地控制接口 || `iphone-control mcp` | 每个 agent 会话一个 | MCP stdio 服务,把工具调用翻译成对守护进程的请求 |-| `usbmuxd` | 容器里是守护进程的子进程;以普通用户从源码运行时用系统的 usbmuxd 服务 | 系统包,GPL-3.0,独立进程运行,不链接 |+| `usbmuxd` | 容器里是守护进程的子进程;Linux 上以普通用户运行时用系统的 usbmuxd 服务;macOS 用系统自带的 | Linux 上是系统包,GPL-3.0,独立进程运行,不链接 || `iphone-control doctor/setup/sign/...` | 一次性 | 运维命令,也通过控制接口或直接调用库 |-**控制接口**:Unix socket(root 默认 `/run/iphone-control/ctl.sock`,普通用户默认 `$XDG_RUNTIME_DIR/iphone-control/ctl.sock`,权限 0600),JSON 行协议。请求/响应类型和客户端 `call(socket, req, timeout)` 在 `ictl-protocol`,MCP 和 CLI 共用。理由:+**控制接口**:Unix socket(root 默认 `/run/iphone-control/ctl.sock`,普通用户默认 `$XDG_RUNTIME_DIR/iphone-control/ctl.sock`,没有这个变量时(macOS)在数据目录下,权限 0600),JSON 行协议。请求/响应类型和客户端 `call(socket, req, timeout)` 在 `ictl-protocol`,MCP 和 CLI 共用。理由:- MCP 进程由 `docker exec -i`(从源码运行时直接调用二进制)拉起,短命且可能同时有多个;设备连接(尤其是 HID 需要的显示媒体流、WDA 的 XCTest 会话)只能有一个持有者。- 不开 TCP 端口,避免重蹈 `ios forward` 监听所有网卡的覆辙。WDA 本身也通过 idevice 的 provider 直连设备端口,**本机不再监听 8100**。如需给外部工具用,`iphone-control wda-bridge` 显式开启,只绑 127.0.0.1,且只转发 Host 头是 `localhost`/`127.0.0.1`/`[::1]` 的请求(挡住 DNS rebinding)。注意容器用 host 网络,**本机的任何用户都能连上 bridge**,而 WDA 没有认证,用完就停。@@ -81,17 +81,17 @@WdaStarting:后台任务 开隧道 → 查/挂开发者镜像 → 关隧道 → 启动 runner(最长 120 秒)│ 结果由下一轮巡检收├─ 成功 ──────────────────────────────▶ 健康检查通过后 Ready- ├─ 隧道报 PasswordProtected(锁屏/BFU)─▶ NeedsUnlock(BFU 必须人工)+ ├─ 隧道报 PasswordProtected(锁屏/BFU)─▶ NeedsUnlock(BFU 必须人工,定期重试,状态不来回变)├─「Enable UI Automation」超时 ─────────▶ NeedsAutomationPin(推送通知,60 秒重试,不指数退避)└─ 镜像或 WDA 其它失败 ─────────────────▶ WdaStarting { last_error },按退避重试```要点(每一条都来自 toolkit 实际踩过的坑):-- **热插拔**:容器里没有 udev,usbmuxd 收不到热插拔事件。守护进程同时做两件事:订阅 usbmuxd 的 `Listen` 事件;并每 10 秒检查 sysfs `/sys/bus/usb/devices/*/idVendor` 是否有 `05ac`。连续 3 次"USB 上有 Apple 设备但 usbmuxd 看不到"就重启 usbmuxd 子进程。列设备连续 3 轮出错才当作离线,usbmuxd 抖一下不拆会话。+- **热插拔**:容器里没有 udev,usbmuxd 收不到热插拔事件。守护进程每 10 秒向 usbmuxd 列一次设备,并数 sysfs `/sys/bus/usb/devices/` 里的 iPhone/iPad/iPod(厂商号 `05ac` 且产品名匹配,键盘等配件不算)。只在自管 usbmuxd 时:sysfs 里的台数连续 3 次多于 usbmuxd 认到的台数就重启 usbmuxd 子进程。列设备连续 3 轮出错才当作离线,usbmuxd 抖一下不拆会话。- **隧道**:CoreDeviceProxy + jktcp 用户态 TCP 栈(idevice `tunnel_tcp_stack`),不需要 root,不创建 TUN 网卡。锁屏且从未解锁过(BFU)时报 `PasswordProtected`,进入 `NeedsUnlock`,只能人工解锁。HID 和截图用的隧道按需建立、常驻复用;WDA 掉线或 usbmuxd 重启时连隧道一起丢。- **HID 会话**:归 `Tunnel` 所有(`Tunnel::hid` / `close_hid` / `close`),持有屏幕媒体流。关闭时必须先停媒体流再断隧道,否则手机一直挂着「配对的电脑」会话(灵动岛图标常驻、不自动锁屏)。空闲 30 秒关闭,重开约 0.5 秒。-- **开发者镜像**:每次启动 WDA 前都先 `installed_ddi()` 查询(toolkit 实测已挂载时约 1 秒),未挂载才走 `install_ddi()`(个性化 + TSS)。手机重启后镜像可能会掉,所以这一步不能省。连续 3 次挂载失败就清掉 DDI 缓存重新下载。+- **开发者镜像**:每次启动 WDA 前都先 `installed_ddi()` 查询(toolkit 实测已挂载时约 1 秒),未挂载才走 `install_ddi()`(个性化 + TSS)。手机重启后镜像可能会掉,所以这一步不能省。默认缓存(`ddi/`)连续 3 次**挂载**失败才清掉重新下载,隧道建不起来不计入。设了 `ICTL_DDI_DIR` 时不下载、也不删里面的文件,缺文件时报错说明缺哪个。- **WDA 就绪判定**:必须同时满足"本进程持有的 XCTest 会话存活"和 `/status` 返回 ready。toolkit 踩过:host 侧 runner 退出后,手机上残留的 WDA 还会响应几十秒再自杀,单看 `/status` 会误判。- **自动化密码框**:手机重启后首次启用 UI 自动化会弹「为 XCTest 输入 iPhone 密码」,没人输就报 `Timed out while enabling automation mode`。识别到这个错误:进入 `NeedsAutomationPin`、只推送一次通知、保持 60 秒重试;恢复后再推送一次。- **退避**:其它 WDA 启动失败按 60s → 120s → 240s → 300s 退避,上限 5 分钟;手机重新连上、WDA 就绪、重签完成时重置。@@ -105,44 +105,38 @@| `ictl-protocol` | 控制接口的 `Request`/`Response` 类型和客户端 `call(socket, req, timeout)` | `serde`、`tokio` || `ictl-sign` | Apple ID 登录(含双重认证交互)、会话持久化、注册设备、App ID、描述文件、签名 `.app`/`.ipa`(**包括 `.xctest`**;bundle 逻辑改写自 plume_utils)、签后自检 | vendored 的 `plume_core`/`plume_store`(MPL-2.0/MIT;经 plume_core 用 vendored 的 `omnisette` 和打过补丁的 `apple-codesign`) || `ictl-unlock` | 锁屏密码键盘定位、逐位输入并核对密码栏、从第 2 位起先写停用标记 | `ictl-wda` |-| `ictl-daemon` | `core`(共享状态、请求分发、快照)、`supervise`(巡检、usbmuxd 看护、后台启动 WDA、重签、会话检查)、`tools`(13 个工具的实现、HID 后备)、`doctor`;通知(Bark/Telegram)、截图缩放/裁剪、控制接口服务端 | 以上全部、`tokio`、`reqwest`、`image` |-| `ictl-mcp` | MCP stdio 服务,toolkit 的 13 个 `iphone_*` 工具 + `iphone_wait_for`、`iphone_batch`;操作类工具可带 `then` 顺带返回操作后的界面;经控制接口调用守护进程 | `ictl-protocol`、`rmcp`(`server`、`transport-io`) |-| `apps/iphone-control` | CLI 入口:`daemon`、`mcp`、`mcp-config`、`status`、`doctor`、`setup`、`login`、`sign`、`resign`、`passcode`、`unlock-reset`、`wda-bridge`、`notify-test`;隐藏的 `debug <ddi\|hid\|screenshot\|soak\|wda\|e2e>` 真机诊断(原第 0 步 spike,不经守护进程) | `clap` |+| `ictl-daemon` | `core`(共享状态、请求分发、快照)、`supervise`(巡检、usbmuxd 看护、后台启动 WDA、重签、会话检查)、`tools`(工具的实现、HID 后备)、`devices`(列出、选择设备)、`doctor`;通知(Bark/Telegram)、截图缩放/裁剪、控制接口服务端 | 以上全部、`tokio`、`reqwest`、`image` |+| `ictl-mcp` | MCP stdio 服务,17 个 `iphone_*` 工具:toolkit 的 13 个 + `iphone_wait_for`、`iphone_batch`、`iphone_list_devices`、`iphone_select_device`;操作类工具可带 `then` 顺带返回操作后的界面;经控制接口调用守护进程 | `ictl-protocol`、`rmcp`(`server`、`transport-io`) |+| `apps/iphone-control` | CLI 入口:`daemon`、`mcp`、`mcp-config`、`status`、`doctor`、`setup`、`login`、`sign`、`resign`、`passcode`、`unlock-reset`、`devices`、`select`、`wda-bridge`、`notify-test`;隐藏的 `debug <ddi\|hid\|screenshot\|soak\|wda\|e2e>` 真机诊断(原第 0 步 spike,不经守护进程;feature `debug-cmds`,默认不编译) | `clap` |-依赖方向:`apps` → `ictl-daemon` / `ictl-mcp`;`ictl-daemon` → `ictl-unlock` → `ictl-wda` → `ictl-device`;`ictl-daemon` 还依赖 `ictl-sign` 和 `ictl-protocol`。`ictl-mcp` 只依赖 `ictl-protocol`,不依赖守护进程和设备层。`apps` 的 `debug` 直接调用 `ictl-device`、`ictl-wda`。+依赖方向:`apps` → `ictl-daemon` / `ictl-mcp`;`ictl-daemon` → `ictl-unlock` → `ictl-wda` → `ictl-device`;`ictl-daemon` 还依赖 `ictl-sign` 和 `ictl-protocol`。`ictl-mcp` 只依赖 `ictl-protocol`,不依赖守护进程和设备层。`apps` 的 `debug`(feature `debug-cmds`)直接调用 `ictl-device`、`ictl-wda`。## 5. 截图与坐标-- 坐标单位统一用**点(pt)**,与 WDA 一致;屏幕点尺寸从 WDA `/wda/screen` 读取并缓存到 `state.json`,WDA 不可用时用缓存值,从没连上过 WDA 时用 `.env` 的 `SCREEN_W`/`SCREEN_H`(不写死 430×932)。-- HID 坐标是 0~65535 归一化,换算 `x / w * 65535`。+- 坐标单位统一用**点(pt)**,与 WDA 一致,随界面方向变化;屏幕点尺寸从 WDA `/wda/screen` 读取。WDA 就绪时把竖放尺寸和设备 UDID 记到 `state.json`(只记最近一台)。WDA 不可用时:记录是这台的就用记录,否则用 `.env` 的 `SCREEN_W`/`SCREEN_H`(不分设备),都没有就报错(不写死 430×932)。+- HID 坐标是 0~65535 归一化:先按界面方向转回竖放(`Rotation::to_portrait`),再换算 `x / w * 65535`。每次 HID 触摸前重新截图核对横竖;横屏要有 30 秒内且匹配的 WDA 旋转角,否则拒绝触摸。- 截图优先走 WDA(toolkit 实测约 0.4 秒);WDA 不可用时走 CoreDevice `screencaptureservice`(不需要签名)。- 区域放大:从原始像素截图裁剪,长边 < 600 放大到 600,> 1200 缩到 1200,返回倍数和坐标换算式(三位有效数字)。## 6. 数据与秘密目录-全部在一个数据根目录下(root 默认 `/var/lib/iphone-control`,容器里挂卷;普通用户默认 `~/.local/share/iphone-control`):+全部在一个数据根目录下(root 默认 `/var/lib/iphone-control`,容器里挂卷;普通用户默认 `$XDG_DATA_HOME/iphone-control`,没设时 `~/.local/share/iphone-control`,macOS 相同)。数据根目录是 0700;下表权限写「默认」的没有单独设,靠它保护:| 路径 | 内容 | 权限 | 进 git / 进镜像 ||---|---|---|---|-| `lockdown/` | 配对记录(容器里的 usbmuxd 读写,即 `/var/lib/lockdown`;用系统的 usbmuxd 服务时不用这里,记录在系统的 `/var/lib/lockdown`) | 0700 | 否 |+| `lockdown/` | 配对记录(容器里的 usbmuxd 读写,即 `/var/lib/lockdown`;用系统的 usbmuxd 服务时不用这里,记录在系统的 `/var/lib/lockdown`;macOS 在 `/var/db/lockdown`,和 Finder 共用) | 0700 | 否 || `account/` | Apple ID 会话、开发私钥、证书 | 0700 | 否 |-| `profiles/` | 当前描述文件 | 0700 | 否 |-| `ddi/` | 开发者镜像缓存(运行时下载的苹果文件) | 0755 | **否,不得分发** |-| `wda/` | 当前签好的包 `WDA-signed.ipa`。未签名包在镜像的 `/usr/share/iphone-control/WDA-unsigned.ipa`:构建时下载 Appium 官方的未签名真机包(`WebDriverAgentRunner-Runner.zip` v16.15.3,校验 sha256)重新打包。从源码运行时没有镜像,第一次签名前按同一版本下载、校验,转成 `wda/WDA-unsigned.ipa`(`crates/ictl-daemon/src/wda_pkg.rs`,版本与 Dockerfile 由单测核对);计划改为本项目 macOS CI 编译 | 0755 | 未签名包进镜像(从源码运行时在本机下载) |+| `ddi/` | 开发者镜像缓存(运行时下载的苹果文件);设了 `ICTL_DDI_DIR` 时用那个目录,不用这里 | 默认 | **否,不得分发** |+| `wda/` | 当前签好的包 `WDA-signed.ipa`。未签名包在镜像的 `/usr/share/iphone-control/WDA-unsigned.ipa`:构建时下载 Appium 官方的未签名真机包(`WebDriverAgentRunner-Runner.zip` v16.15.3,校验 sha256)重新打包。从源码运行时没有镜像,第一次签名前按同一版本下载、校验,转成 `wda/WDA-unsigned.ipa`(`crates/ictl-daemon/src/wda_pkg.rs`,版本与 Dockerfile 由单测核对);计划改为本项目 macOS CI 编译。描述文件只嵌在签好的包里,到期时间记在 `state.json` | 默认 | 未签名包进镜像(从源码运行时在本机下载) || `secrets/passcodes/<UDID>` | 各设备的锁屏密码(仅启用自动解锁时);旧版本的 `secrets/passcode` 在只接着一台时归到那台名下 | 0600 | 否 |-| `notify.toml` | 通知渠道配置 | 0600 | 否 |-| `logs/` | 日志,按大小轮转 | 0755 | 否 |-| `state.json` | 状态机快照、自动解锁停用标记、上次重签结果 | 0600 | 否 |+| `logs/` | 日志,按大小轮转;自动解锁停用标记 `UNLOCK-DISABLED`(与 toolkit 一致,便于人工发现;全局,不分设备) | 默认 | 否 |+| `state.json` | 最近一次签名的 Team ID、WDA Bundle ID、描述文件到期时间;选定的设备;最近一台就绪设备的竖放屏幕尺寸和 UDID;上次重签结果 | 默认 | 否 |-没有配置文件:配置全部来自环境变量(容器里由 `.env` 注入,从源码运行时由 shell 或 systemd 的 `EnvironmentFile` 给,见 `.env.example`、`crates/ictl-daemon/src/config.rs`),都有默认值;秘密只放文件。--实现与上表的差异(2026-11-01):-- 没有单独的 `profiles/` 和 `notify.toml`:描述文件只嵌在 `wda/WDA-signed.ipa` 里,到期时间记在 `state.json`;通知渠道走环境变量(`.env`),见 `.env.example`。-- 自动解锁停用标记在 `logs/UNLOCK-DISABLED`(与 toolkit 一致,便于人工发现)。+没有配置文件,通知渠道也一样:配置全部来自环境变量(容器里由 `.env` 注入,从源码运行时由 shell 或 systemd 的 `EnvironmentFile` 给,见 `.env.example`、`crates/ictl-daemon/src/config.rs`),都有默认值;秘密只放文件。## 7. 重签与通知-- 守护进程每 `RESIGN_CHECK_HOURS`(默认 6 小时)检查一次:描述文件剩余 < `RESIGN_MIN_DAYS`(默认 2 天)才重签;另外**每天验证一次 Apple ID 会话**(toolkit 的教训:只在要重签时才发现登录过期,只剩 2 天处理)。两者都在后台跑,不持设备锁。-- 重签流程:`plume_core` 取新描述文件 → `ictl-sign` 签名(含 `.xctest`)→ `installation_proxy` 安装 → 下一轮巡检重启 WDA。安装成功后才替换旧文件。-- 通知事件:重签失败、Apple ID 会话失效、需要输入自动化密码、WDA 恢复、自动解锁失败已停用、手机离线超过 10 分钟。同一事件不重复推送,恢复时推送一次。+- 守护进程每 `RESIGN_CHECK_HOURS`(默认 6 小时)检查一次:描述文件剩余 < `RESIGN_MIN_DAYS`(默认 2 天)才重签;另外**每天验证一次 Apple ID 会话**(toolkit 的教训:只在要重签时才发现登录过期,只剩 2 天处理)。两者都在后台跑,不持设备锁。只检查正在控制的那台;手机重新连上或切换设备后 1 分钟内也查一次。+- 重签流程:`plume_core` 取新描述文件 → `ictl-sign` 签名(含 `.xctest`)→ `installation_proxy` 安装 → 下一轮巡检重启 WDA。安装成功后才替换旧文件。整个重签有总时限,超时按失败处理并推送通知。没装过当前 Apple ID 签的 WDA 的设备不自动重签(注册设备占 Apple ID 的名额,交给用户决定)。+- 通知事件:重签失败、Apple ID 会话失效、需要输入自动化密码、WDA 恢复、自动解锁失败已停用、手机离线超过 10 分钟、恢复在线。通知文字不带设备名。去重:重签失败、会话失效 20 小时内不重复;等密码、离线、自动解锁停用推一次,直到恢复或 `unlock-reset`;只有等密码和离线有恢复推送。去重记录只在内存里,守护进程重启后清空。- 容器整个挂掉时守护进程发不了通知,这部分仍需宿主机侧的监控,本项目还没有提供。从源码运行时 `deploy/iphone-control.service` 只负责崩溃后重启,同样不报警。diff --git a/docs/decisions.md b/docs/decisions.mdindex aa9c723..8b4a5ae 100644--- a/docs/decisions.md+++ b/docs/decisions.md@@ -7,7 +7,7 @@- **决定**:设备通讯全部基于 `idevice`。版本用 `[patch.crates-io]` 锁在上游 master 的 git 提交 `89702099`(0.1.68 发版代码的 cryptexd install 会挂住,修复已在 master、未发版);发版后换回 crates.io。- **理由**:它已覆盖我们需要的全部能力:usbmuxd、lockdown、CoreDeviceProxy 用户态隧道、RSD、cryptexd 个性化镜像安装、universalhidservice/indigo HID、screencaptureservice、XCTest 启动 WDA、WDA 客户端;MIT;StikDebug、CrossCode 等在生产中使用;Impactor 也依赖它,和签名部分同源。- **代价**:0.2.0 之前每个小版本都可能有破坏性变更;主要一人维护;`tss` 自述部分支持、TCP 栈自述 "naive"。-- **重新评估**:spike 第 4、5 项不过时(已全部通过,见 [spike-results](dev/spike-results.md))。+- **重新评估**:spike 第 4、5 项不过时(已全部通过,见 [spike-results](dev/archive/spike-results.md))。## D2:守护进程独占设备,MCP 是薄客户端@@ -29,7 +29,7 @@## D5:保留系统 usbmuxd,作为子进程看护-- **决定**:不内置 USB 协议栈,使用 Debian 的 `usbmuxd`。+- **决定**:不内置 USB 协议栈。Linux 上使用 Debian 的 `usbmuxd`:容器里作为子进程看护,以普通用户运行时用系统服务。macOS 用系统自带的 usbmuxd,守护进程不启动也不重启它。- **理由**:idevice 只有 usbmuxd 客户端;自己实现 USB 多路复用收益很小;usbmuxd 是 GPL-3.0,作为独立进程运行不影响本项目许可证。- **代价**:仍需处理容器无 udev 的热插拔问题(sysfs 兜底 + 重启)。@@ -48,7 +48,7 @@## D8:自动解锁默认关闭- **决定**:需要显式开启并配置密码文件。-- **理由**:存储锁屏密码意味着能访问主机的人就能解锁手机;输错累计还可能触发设备抹除。保护规则见 [capability-matrix §5](dev/capability-matrix.md)。+- **理由**:存储锁屏密码意味着能访问主机的人就能解锁手机;输错累计还可能触发设备抹除。保护规则见 `crates/ictl-unlock/src/lib.rs` 顶部注释。## D9:所有依赖锁定精确版本@@ -57,8 +57,15 @@## D10:与 toolkit 工具接口一致-- **决定**:13 个 MCP 工具名、参数、返回文本格式保持与 toolkit 一致。+- **决定**:现在共 17 个 MCP 工具,其中来自 toolkit 的 13 个,工具名、参数、返回文本格式保持与 toolkit 一致。- **理由**:切换时 agent 侧零改动;toolkit 的回归脚本可直接用于验收。- **补充(2026-11-01)**:只做向后兼容的扩展,不改已有工具的名字、参数和默认返回。为减少 agent 往返(每次往返是一轮模型推理,真机观察约 8~13 秒,远大于工具本身的 0.3~1.5 秒),操作类工具加可选参数 `then`(`elements` / `screenshot`:等界面稳定后- 顺带返回界面),并新增 `iphone_wait_for`(等某段文字出现)和 `iphone_batch`(一次执行最多 20 步,出错即停)。+ 顺带返回界面),并新增 `iphone_wait_for`(等某段文字出现)和 `iphone_batch`(一次执行最多 20 步,出错即停)。多设备的 `iphone_list_devices`、`iphone_select_device` 见 D11。++## D11:接多台设备时,同一时间只控制一台++- **决定**:一个守护进程可以接多台 iPhone/iPad,但只控制一台(一个 WDA 会话、一把设备锁)。优先级:`IPHONE_UDID` 固定 > 运行中选定的(`select`、`iphone_select_device`,持久化到 `state.json`)> 自动选(正在控制的那台一直用到它断开)。选定的那台没接时就是离线,不静默换到另一台。锁屏密码按设备存;自动解锁的停用标记是全局的。+- **理由**:操作或密码落到另一台手机上后果严重,所以宁可离线也不换台,密码也绝不跨设备使用。同时控制多台要多套会话,每个工具还要加设备参数,和 D10 的接口兼容冲突。停用标记全局是偏保守的选择:一台失败后先让人看一眼。+- **代价**:选定的设备没接时可能触发离线通知;一台自动解锁失败,所有设备都停用;切换后 WDA 要 10~60 秒才起来;自动重签只管正在控制的那台,闲置设备的描述文件会过期,切回后才重签;通知文字不带设备名。+- **重新评估**:出现同时驱动多台的需求时。diff --git a/docs/dev/capability-matrix.md b/docs/dev/archive/capability-matrix.mdsimilarity index 98%rename from docs/dev/capability-matrix.mdrename to docs/dev/archive/capability-matrix.mdindex 0942a48..97274e2 100644--- a/docs/dev/capability-matrix.md+++ b/docs/dev/archive/capability-matrix.md@@ -1,5 +1,7 @@# 能力对照表+> **历史记录,0.1.0 前做技术选型时的对照表**,不再更新。现状见[架构](../../architecture.md);自动解锁的规则以 `crates/ictl-unlock/src/lib.rs` 顶部注释为准。+把 toolkit 现有的每项能力,对应到 D 方案里由谁实现。状态说明:diff --git a/docs/dev/roadmap.md b/docs/dev/archive/roadmap.mdsimilarity index 57%rename from docs/dev/roadmap.mdrename to docs/dev/archive/roadmap.mdindex bd404a3..406a0b9 100644--- a/docs/dev/roadmap.md+++ b/docs/dev/archive/roadmap.md@@ -1,5 +1,7 @@# 路线图+> **历史记录,0.1.0 前的规划**,不再更新。文中的「回归用例 #N」在 [regression-cases.md](../regression-cases.md);`iphone-control debug` 现在要用 `--features debug-cmds` 编译才有。现状见[架构](../../architecture.md)和[更新日志](../../../CHANGELOG.zh-CN.md)。+每个阶段都有明确的完成标准;未达标不进入下一阶段。toolkit 在阶段 7 之前一直是正式版本。## 完成情况@@ -86,41 +88,4 @@ Bark、Telegram;事件见 architecture §7;同一事件去重。## 必须覆盖的回归用例-这些全部是 toolkit 实际踩过的坑。能单测的写单测,不能单测的进真机回归清单。--| # | 坑 | 正确行为 | 测试方式 |-|---|---|---|---|-| 1 | 锁屏密码键盘不显示时,`Key` 元素仍留在元素树里(`visible=false`) | 不以"树里有键盘"判断键盘已出现;固定先唤醒再上滑 | 单测(脱敏 XML 样本)+ 真机 |-| 2 | `displayed` 接口在锁屏上返回 false,即使键盘可见 | 以密码栏「已输入 N 位」为准 | 真机 |-| 3 | 锁屏界面 Face ID 动画使 WDA 每请求等 idle 至 10 秒,键盘随后自动收起 | 解锁期间 `waitForIdleTimeout=1`、`animationCoolOffTimeout=0.2`,结束恢复;0 会导致唤醒失败 | 真机 |-| 4 | 多位密码合成一个 W3C 手势会漏键 | 每位单独一个手势并逐位核对 | 真机 |-| 5 | 锁屏上 `/wda/tap` 每次约 2.9 秒 | 解锁用 W3C 单手势(约 0.7 秒) | 真机计时 |-| 6 | 同名「设置」有 5 个 `SBAppTags` 含 `hidden` 的后台服务 | 按名字解析 App 时跳过 hidden | 单测 |-| 7 | 容器无 udev,手机重启/重插后 usbmuxd 看不到设备 | sysfs 有 `05ac` 但 usbmuxd 无设备连续 3 次 → 重启 usbmuxd | 真机(杀 usbmuxd 模拟) |-| 8 | 手机重启后 XCTest 弹「Enable UI Automation」密码框 | 识别错误、只推送一次、60 秒重试、恢复后再推送 | 单测(错误识别)+ 真机 |-| 9 | plumesign 不签 `.xctest`,WDA 报 XCTest 103 | `.xctest` 签名、无 entitlements | 单测(签完检查 `_CodeSignature`)+ 真机 |-| 10 | `ios forward` 监听所有网卡,WDA 无认证,局域网可直接控制手机 | 默认不监听任何端口;bridge 只绑 127.0.0.1 | 集成测试(检查监听地址) |-| 11 | 依赖大版本漂移(mcp 2.x 把 FastMCP 改名、idevice 0.1.x 每版破坏性变更) | 所有依赖锁定精确版本 + `Cargo.lock` 入库;升级单独提交 | CI |-| 12 | host 侧 runner 退出后手机上残留 WDA 仍响应几十秒 | 就绪 = 本进程 XCTest 会话存活 且 `/status` ready | 真机 |-| 13 | App 冷启动后立即点击会被吞 | `launch_app` 等到前台再停 1 秒 | 真机 |-| 14 | 完整元素树 7~8 秒 | `excluded_attributes` 排除可见性等属性(约 0.3 秒),可见性按坐标判断 | 单测 + 计时 |-| 15 | 铺满全屏的 Application/Window/Toolbar 等元素没有定位价值 | 列表中过滤 | 单测 |-| 16 | 区域放大倍数只保留 2 位有效数字导致边缘约 1.4 点误差 | 保留 3 位 | 单测 |-| 17 | 只有 ToolError 的消息能透传给 MCP 客户端(Python SDK) | 所有预期错误都转成工具错误文本 | 单测 |-| 18 | 锁屏(未首次解锁)时隧道报 `PasswordProtected` | 进入 NeedsUnlock,提示人工 | 真机 |-| 19 | Apple ID 会话过期只在重签时才发现 | 每日独立验证会话 | 单测(模拟过期) |-| 20 | WDA 在锁屏时启动,`/wda/locked` 一直报 false(只靠变化通知维护,初值 false) | 本次 WDA 启动后确认过一次未锁屏之前,用元素树核对(锁图标 `proud-lock` / `passcode-view`) | 单测(iOS 27 真机样本)+ 真机 |-| 21 | 下拉通知中心时 `/wda/locked` 报 true | WDA 说锁了时核对元素树:只有 `lockscreen-date-view`、没有锁图标的是通知中心 | 单测(真机样本)+ 真机 |-| 22 | iOS 27 上锁屏密码键盘有残留输入时,按 Home 不清空(键隐藏但仍可按) | 用右下角删除键逐位删到 0(按位置认,不依赖语言),每删一位核对 | 单测(真机样本 + 假锁屏)+ 真机 |-| 23 | 熄屏锁屏时第一个无障碍查询等约 8 秒;锁屏 0.5 秒内唤醒,第一下上滑卡约 16 秒后报 `point.x != INFINITY` | 能自动解锁时先按 Home 再核对;本进程锁屏后 3 秒内不解锁;唤醒/上滑报错算这轮落空重来 | 单测 + 真机计时 |-| 24 | HID 会话的屏幕媒体流没正常停止时,手机端一直挂着:灵动岛「配对的电脑」图标常驻、不自动锁屏,进程退出和拔插都清不掉 | HID 空闲 30 秒关闭;所有丢弃路径(含退出)先停流;WDA 锁屏报错时确认已锁就不退到 HID | 真机 |-| 25 | 自动解锁第 2 位之后出错(点击报错、核对锁屏报错、进程被杀)会跳过写停用标记,下次可能把同一个错误密码再输一遍 | 输第 2 位之前先写停用标记,只有确认解开或确认没凑满整串才撤掉;出错返回 `UnlockError::Uncertain` 并推送通知 | 单测(`ictl-unlock`:`error_after_second_digit_keeps_auto_unlock_disabled`、`double_press_that_fills_the_entry_disables`、`dropped_last_digit_is_not_a_wrong_attempt`) |-| 26 | 最后一位输完后用 WDA 的锁屏状态确认结果:WDA 在锁屏时启动会报 false,把输错当成解开 | 确认时用严格判断 `WdaClient::check_lock(_, strict = true)`:核对出错一律算仍锁着 | 单测(`stale_wda_lock_state_cannot_turn_a_wrong_entry_into_unlocked`) |-| 27 | HID 会话在屏幕媒体流起来之后才失败,媒体流没停(症状同 #24) | `HidSession::open`、`media::start` 出错时先停流;HID 会话归 `Tunnel` 所有,关隧道必先停流 | 真机 |-| 28 | 一个长操作(启动 WDA 等自动化密码最长 120 秒)挡住所有工具、`status` 和 SIGTERM,排队的点击几分钟后才执行 | 启动 WDA、重签、会话检查不持设备锁;`status` 读快照;改变手机状态的请求排队超过 30 秒就放弃;停止信号优先处理(architecture §2 并发模型) | 真机 |-| 29 | WDA 请求超时后退到 HID,同一个动作做了两遍 | 传输层区分连不上(`WdaError::Unavailable`,可以退到 HID)和请求已发出后超时(`WdaError::Timeout`,不退) | 单测 + 代码审查 |-| 30 | `.env` 里留空的 `ICTL_LOG=` 生成一个什么都不放行的过滤器,日志全没了 | 空值当作没设 | 真机(`docker logs`) |-| 31 | `/wda/tap` 每次先等界面空闲:主屏点图标约 1.7 秒(调小等待设置也没用);W3C actions 手势做完又要等动画冷却(默认 2 秒),App 里切标签约 1.9 秒 | 点击用单个 actions 手势,期间临时把 waitForIdleTimeout/animationCoolOffTimeout 调成 1/0.2,做完恢复(原值只读一次)。真机:主屏点图标 1.70→0.91 秒(到前台 1.80→1.01 秒),App 里 0.62→0.72 秒 | 单测(请求顺序、恢复原值)+ 真机计时 |-| 32 | `/wda/keys` 没有输入框获得焦点时也返回成功,什么都没输(真机:Safari 地址栏没点中、主屏上直接输入) | 输入前查屏幕上有没有软键盘(`XCUIElementTypeKeyboard`,约 0.2 秒),没有就报错让先点输入框 | 真机 |-| 33 | 系统弹窗(定位、通知权限)挡着时 Home 不生效、App 到不了前台,WDA 照样报成功;弹窗属于 SpringBoard,看前台 App 发现不了 | 按 Home 前查 `/alert/text`(App 静止时约 0.4 秒;按下后动画中查要好几秒);有弹窗就说明并不按。launch_app 没到前台时同样带上弹窗文字。按 Home 后等主屏到前台再返回 | 真机计时;弹窗路径待弹窗再出现时复测 |-| 34 | `/wda/touchAndHold` 前后都等界面空闲:主屏长按图标 1.2 秒要约 12 秒 | 长按和点击一样用单个 actions 手势、临时调小等待:约 2 秒 | 真机计时 |+已拆到 [regression-cases.md](../regression-cases.md)。diff --git a/docs/dev/spike-plan.md b/docs/dev/archive/spike-plan.mdsimilarity index 96%rename from docs/dev/spike-plan.mdrename to docs/dev/archive/spike-plan.mdindex 23cca3a..3079b2b 100644--- a/docs/dev/spike-plan.md+++ b/docs/dev/archive/spike-plan.md@@ -1,7 +1,7 @@# 第 0 步:真机验证(spike)-> **已完成(2026-11-01),本文留作历史记录。** 5 项全部通过,结果见 [spike-results.md](spike-results.md)。-> 文中的 `spike/` 程序已删除,有用的子命令并入隐藏命令 `iphone-control debug <ddi|hid|screenshot|soak|wda|e2e>`(`apps/iphone-control/src/debug.rs`)。+> **历史记录,0.1.0 前的计划**,已完成(2026-11-01),不再更新。5 项全部通过,结果见 [spike-results.md](spike-results.md)。+> 文中的 `spike/` 程序已删除,有用的子命令并入隐藏命令 `iphone-control debug <ddi|hid|screenshot|soak|wda|e2e>`(`apps/iphone-control/src/debug.rs`,要用 `--features debug-cmds` 编译才有)。目的:用最少的代码确认 idevice 在目标设备(iPhone 15 Pro Max,iOS 27.0.1)上能完成 D 方案依赖的 5 项关键能力。**这一步的结果决定 D 方案是否继续。**diff --git a/docs/dev/spike-results.md b/docs/dev/archive/spike-results.mdsimilarity index 89%rename from docs/dev/spike-results.mdrename to docs/dev/archive/spike-results.mdindex fa4c352..21e7abd 100644--- a/docs/dev/spike-results.md+++ b/docs/dev/archive/spike-results.md@@ -1,5 +1,7 @@# spike 结果+> **历史记录,2026-11-01 第 0 步的结果**,不再更新。文中的 `iphone-control debug` 现在要用 `--features debug-cmds` 编译才有。+设备:iPhone 15 Pro Max(iPhone16,2),iOS 27.0.1(24A446)。日期:2026-11-01。环境:单独的 spike 容器(`--privileged`,挂 `/dev/bus/usb`,容器内 Debian usbmuxd 1.1.1),程序为当时的 `spike/` crate(`cargo build --release -p ictl-spike`)。@@ -16,6 +18,8 @@| 4 | 隧道稳定性 | ✅ 通过(部分) | 30 分钟 529 次截图 0 失败,共 4.1GB,最慢 1.49s;锁屏、内存未记录 || 5 | 启动 WDA | ✅ 通过 | 2.1s 就绪;元素树 42KB/0.25s;截图 433KB/0.18s |+> 下文的「未覆盖」和「待补」是当时的状态。后来确认的结论见[路线图的完成情况](roadmap.md#完成情况):HID 点击和 Home 已由 `debug e2e` 以前台 App 变化确认生效;「Enable UI Automation」的报错文字已确认(回归用例 [#8](../regression-cases.md));从未挂载开始的挂载流程在 iOS 27 上仍没测到(重启后镜像还在)。+## 1. 开发者镜像- 挂载前 `copy-installed` 返回空数组(未挂载)。diff --git a/docs/dev/macos-verification.md b/docs/dev/macos-verification.mdindex 98254cd..cd020f2 100644--- a/docs/dev/macos-verification.md+++ b/docs/dev/macos-verification.md@@ -1,5 +1,7 @@# macOS 真机验证+> **下面的验证记录早于 0.1.3**:多设备工具(`iphone_list_devices`、`iphone_select_device`,命令 `devices`、`select`)没有在 macOS 上验证过。+CI 已经确认项目在 macOS(Apple Silicon)上能编译、链接,单元测试全部通过(PR #12),但单元测试不连手机。这份文档是在一台插着 iPhone 的 Mac 上要跑的步骤,换了 macOS、iOS 版本或机型时可以照着重跑一遍。## 已有的验证记录@@ -39,7 +41,7 @@ CI 已经确认项目在 macOS(Apple Silicon)上能编译、链接,单元## 准备- **Mac**:Apple Silicon。Intel Mac 也可以测,结果单独记录。-- **iPhone**:iOS 17.4 以上,项目实测过的是 iPhone 15 Pro Max(iOS 27.0.1)。用**数据线**连接。+- **iPhone**:iOS 17 以上,这份清单实测过的是 iPhone 15 Pro Max(iOS 27.0.1)。用**数据线**连接。- **Apple ID**:免费的即可,建议用专门的账号,不用主账号。- **系统语言**:回归脚本的默认步骤按中文 App 名(「时钟」「设置」)操作,手机最好设为简体中文;不是的话第 3 步要改步骤。- **不需要装 Xcode**。如果已经装了,第 4 步多测一个场景。@@ -51,7 +53,7 @@ CI 已经确认项目在 macOS(Apple Silicon)上能编译、链接,单元xcode-select --install # 命令行工具:C 编译器、git(已装会提示)curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Rust,1.88 以上即可git clone https://github.com/Derrors/iphone-control && cd iphone-control-cargo install --path apps/iphone-control --locked # 装到 ~/.cargo/bin/iphone-control+cargo install --path apps/iphone-control --locked --features debug-cmds # 装到 ~/.cargo/bin/iphone-control;第 2 步和第 4 步 D 的 debug 命令要这个 featureiphone-control --version```@@ -116,7 +118,7 @@ iphone-control doctor # 每一项都应是 ✅## 第 2 步:隧道、开发者镜像、截图、HID-这些检查直接操作手机,**先在终端 A 按 Ctrl-C 停掉守护进程**。停掉后,手机灵动岛(或状态栏)上「配对的电脑」图标应该在几秒内消失;如果一直不消失,记录下来。+`debug` 子命令默认不编译,预编译二进制里也没有,要用上面「安装」里带 `--features debug-cmds` 的命令装。这些检查直接操作手机,**先在终端 A 按 Ctrl-C 停掉守护进程**。停掉后,手机灵动岛(或状态栏)上「配对的电脑」图标应该在几秒内消失;如果一直不消失,记录下来。`--width`、`--height` 是屏幕的点尺寸,默认 430×932(Pro Max 机型)。其他机型请换成对应尺寸(例如 6.1 英寸 Pro 是 393×852)。@@ -180,7 +182,7 @@ done| A. 基线 | 关掉 Finder 窗口,只跑循环 || B. Finder | 打开 Finder,在侧边栏选中这部 iPhone,停在它的页面上,跑循环;中途切换几次「通用」「文件」等标签 || C. Xcode(装了才测) | 打开 Xcode 的 Window → Devices and Simulators 并选中这部手机,跑循环 |-| D. 隧道长测 | 停掉守护进程,Finder 保持选中手机,运行 `iphone-control debug soak --minutes 30`(同一条隧道持续截图) |+| D. 隧道长测 | 停掉守护进程,Finder 保持选中手机,运行 `iphone-control debug soak --minutes 30`(同一条隧道持续截图;要 `--features debug-cmds`) || E. 恢复 | 守护进程运行中:拔线再插回;锁屏再解锁;重启手机(重启后要手动解锁并输一次密码)。每次都看多久回到就绪 |每个场景看三处:diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.mdnew file mode 100644index 0000000..0896d14--- /dev/null+++ b/docs/dev/regression-cases.md@@ -0,0 +1,51 @@+# 必须覆盖的回归用例++#1~#34 来自 toolkit 和本项目早期实际踩过的坑,#35 起是多设备和 HID 横屏。能单测的写单测,不能单测的进真机回归清单:改了设备、时序、WDA 相关的代码,要在真机上重跑相关的用例,并在 PR 里写明跑了哪些、用什么设备和 iOS 版本。++| # | 坑 | 正确行为 | 测试方式 |+|---|---|---|---|+| 1 | 锁屏密码键盘不显示时,`Key` 元素仍留在元素树里(`visible=false`) | 不以"树里有键盘"判断键盘已出现;固定先唤醒再上滑 | 单测(脱敏 XML 样本)+ 真机 |+| 2 | `displayed` 接口在锁屏上返回 false,即使键盘可见 | 以密码栏「已输入 N 位」为准 | 真机 |+| 3 | 锁屏界面 Face ID 动画使 WDA 每请求等 idle 至 10 秒,键盘随后自动收起 | 解锁期间 `waitForIdleTimeout=1`、`animationCoolOffTimeout=0.2`,结束恢复;0 会导致唤醒失败 | 真机 |+| 4 | 多位密码合成一个 W3C 手势会漏键 | 每位单独一个手势并逐位核对 | 真机 |+| 5 | 锁屏上 `/wda/tap` 每次约 2.9 秒 | 解锁用 W3C 单手势(约 0.7 秒) | 真机计时 |+| 6 | 同名「设置」有 5 个 `SBAppTags` 含 `hidden` 的后台服务 | 按名字解析 App 时跳过 hidden | 单测 |+| 7 | 容器无 udev,手机重启/重插后 usbmuxd 看不到设备 | sysfs 里 iPhone/iPad/iPod 的台数连续 3 次多于 usbmuxd 认到的台数 → 重启 usbmuxd(只在自管 usbmuxd 时) | 单测(`usbmuxd_restart_after_three_misses`)+ 真机(杀 usbmuxd 模拟) |+| 8 | 手机重启后 XCTest 弹「Enable UI Automation」密码框 | 识别错误、只推送一次、60 秒重试、恢复后再推送 | 单测(错误识别)+ 真机 |+| 9 | plumesign 不签 `.xctest`,WDA 报 XCTest 103 | `.xctest` 签名、无 entitlements | 单测(签完检查 `_CodeSignature`)+ 真机 |+| 10 | `ios forward` 监听所有网卡,WDA 无认证,局域网可直接控制手机 | 默认不监听任何端口;bridge 只绑 127.0.0.1 | 集成测试(检查监听地址) |+| 11 | 依赖大版本漂移(mcp 2.x 把 FastMCP 改名、idevice 0.1.x 每版破坏性变更) | 所有依赖锁定精确版本 + `Cargo.lock` 入库;升级单独提交 | CI |+| 12 | host 侧 runner 退出后手机上残留 WDA 仍响应几十秒 | 就绪 = 本进程 XCTest 会话存活 且 `/status` ready | 真机 |+| 13 | App 冷启动后立即点击会被吞 | `launch_app` 等到前台再停 1 秒 | 真机 |+| 14 | 完整元素树 7~8 秒 | `excluded_attributes` 排除可见性等属性(约 0.3 秒),可见性按坐标判断 | 单测 + 计时 |+| 15 | 铺满全屏的 Application/Window/Toolbar 等元素没有定位价值 | 列表中过滤 | 单测 |+| 16 | 区域放大倍数只保留 2 位有效数字导致边缘约 1.4 点误差 | 保留 3 位 | 单测 |+| 17 | 只有 ToolError 的消息能透传给 MCP 客户端(Python SDK) | 所有预期错误都转成工具错误文本 | 单测 |+| 18 | 锁屏(未首次解锁)时隧道报 `PasswordProtected` | 进入 NeedsUnlock,提示人工 | 真机 |+| 19 | Apple ID 会话过期只在重签时才发现 | 每日独立验证会话 | 单测(模拟过期) |+| 20 | WDA 在锁屏时启动,`/wda/locked` 一直报 false(只靠变化通知维护,初值 false) | 本次 WDA 启动后确认过一次未锁屏之前,用元素树核对(锁图标 `proud-lock` / `passcode-view`) | 单测(iOS 27 真机样本)+ 真机 |+| 21 | 下拉通知中心时 `/wda/locked` 报 true | WDA 说锁了时核对元素树:只有 `lockscreen-date-view`、没有锁图标的是通知中心 | 单测(真机样本)+ 真机 |+| 22 | iOS 27 上锁屏密码键盘有残留输入时,按 Home 不清空(键隐藏但仍可按) | 用右下角删除键逐位删到 0(按位置认,不依赖语言),每删一位核对 | 单测(真机样本 + 假锁屏)+ 真机 |+| 23 | 熄屏锁屏时第一个无障碍查询等约 8 秒;锁屏 0.5 秒内唤醒,第一下上滑卡约 16 秒后报 `point.x != INFINITY` | 能自动解锁时先按 Home 再核对;本进程锁屏后 3 秒内不解锁;唤醒/上滑报错算这轮落空重来 | 单测 + 真机计时 |+| 24 | HID 会话的屏幕媒体流没正常停止时,手机端一直挂着:灵动岛「配对的电脑」图标常驻、不自动锁屏,进程退出和拔插都清不掉 | HID 空闲 30 秒关闭;所有丢弃路径(含退出)先停流;WDA 锁屏报错时确认已锁就不退到 HID | 真机 |+| 25 | 自动解锁第 2 位之后出错(点击报错、核对锁屏报错、进程被杀)会跳过写停用标记,下次可能把同一个错误密码再输一遍 | 输第 2 位之前先写停用标记,只有确认解开或确认没凑满整串才撤掉;出错返回 `UnlockError::Uncertain` 并推送通知 | 单测(`ictl-unlock`:`error_after_second_digit_keeps_auto_unlock_disabled`、`double_press_that_fills_the_entry_disables`、`dropped_last_digit_is_not_a_wrong_attempt`) |+| 26 | 最后一位输完后用 WDA 的锁屏状态确认结果:WDA 在锁屏时启动会报 false,把输错当成解开 | 确认时用严格判断 `WdaClient::check_lock(_, strict = true)`:核对出错一律算仍锁着 | 单测(`stale_wda_lock_state_cannot_turn_a_wrong_entry_into_unlocked`) |+| 27 | HID 会话在屏幕媒体流起来之后才失败,媒体流没停(症状同 #24) | `HidSession::open`、`media::start` 出错时先停流;HID 会话归 `Tunnel` 所有,关隧道必先停流 | 真机 |+| 28 | 一个长操作(启动 WDA 等自动化密码最长 120 秒)挡住所有工具、`status` 和 SIGTERM,排队的点击几分钟后才执行 | 启动 WDA、重签、会话检查不持设备锁;`status` 读快照;改变手机状态的请求排队超过 30 秒就放弃;停止信号优先处理(architecture §2 并发模型) | 真机 |+| 29 | WDA 请求超时或中途断开后退到 HID,同一个动作做了两遍 | 传输层区分连不上(`WdaError::Unavailable`,可以退到 HID)和请求已发出之后的超时、断开、响应不完整(不退,报错让 agent 先截图确认) | 单测 + 代码审查 |+| 30 | `.env` 里留空的 `ICTL_LOG=` 生成一个什么都不放行的过滤器,日志全没了 | 空值当作没设 | 真机(`docker logs`) |+| 31 | `/wda/tap` 每次先等界面空闲:主屏点图标约 1.7 秒(调小等待设置也没用);W3C actions 手势做完又要等动画冷却(默认 2 秒),App 里切标签约 1.9 秒 | 点击用单个 actions 手势,期间临时把 waitForIdleTimeout/animationCoolOffTimeout 调成 1/0.2,做完恢复(原值只读一次)。真机:主屏点图标 1.70→0.91 秒(到前台 1.80→1.01 秒),App 里 0.62→0.72 秒 | 单测(请求顺序、恢复原值)+ 真机计时 |+| 32 | `/wda/keys` 没有输入框获得焦点时也返回成功,什么都没输(真机:Safari 地址栏没点中、主屏上直接输入) | 输入前查屏幕上有没有软键盘(`XCUIElementTypeKeyboard`,约 0.2 秒),没有就报错让先点输入框 | 真机 |+| 33 | 系统弹窗(定位、通知权限)挡着时 Home 不生效、App 到不了前台,WDA 照样报成功;弹窗属于 SpringBoard,看前台 App 发现不了 | 按 Home 前查 `/alert/text`(App 静止时约 0.4 秒;按下后动画中查要好几秒);有弹窗就说明并不按。launch_app 没到前台时同样带上弹窗文字。按 Home 后等主屏到前台再返回 | 真机计时;弹窗路径待弹窗再出现时复测 |+| 34 | `/wda/touchAndHold` 前后都等界面空闲:主屏长按图标 1.2 秒要约 12 秒 | 长按和点击一样用单个 actions 手势、临时调小等待:约 2 秒 | 真机计时 |+| 35 | 接着多台时,`devices` / `iphone_list_devices` 漏设备或标错正在控制的那台 | 列出 USB 上每一台的名字、型号、iOS 版本、UDID,标出正在控制哪台、有没有设自动解锁密码 | 真机(两台) |+| 36 | 按 usbmuxd 的列表顺序选设备,列表顺序一变就换了台 | 选定了只认那一台,没接就是离线、不换;没选定时正在控制的那台一直用到它断开 | 单测(`device_pick_is_pinned_or_sticky`)+ 真机(拔掉选定的那台) |+| 37 | `select` 按名字选到了别的设备 | 先比 UDID,再比设备名,最后是名字包含这段文字且只有一台;对上多台就报错,让用 UDID 指定 | 单测(`device_is_found_by_udid_then_name`) |+| 38 | 选定的设备重启守护进程后丢了;设了 `IPHONE_UDID` 还能切走 | 选定的写进 state.json;`IPHONE_UDID` 优先,设了就拒绝切到别的设备 | 真机(`select` 后重启;设 `IPHONE_UDID` 后 `select` 另一台) |+| 39 | 切换后操作还落在上一台,或用了上一台的 App 列表、方向、屏幕尺寸 | 切换时拆掉上一台的会话,清掉 App 列表和方向;屏幕尺寸记录是别的设备的就不用。切换后等 `iphone_status` 就绪,截图、`iphone_list_apps`、点击都要作用在新设备上 | 真机(iPhone + iPad,各做一遍 `iphone_select_device` → 截图 → 点击) |+| 40 | 一台的密码输进另一台 | 密码按设备存(`secrets/passcodes/<UDID>`);旧的 `secrets/passcode` 只在 USB 上只接着一台时归到那台,接着多台时不用 | 单测(`passcode_file_is_per_device_and_stays_in_its_dir`)+ 真机 |+| 41 | 已接着一台时再插一台,没有 udev 的 usbmuxd 认不到第二台 | 比台数,不只看「有没有设备」 | 单测(`usbmuxd_restart_when_a_second_device_is_missed`)+ 真机 |+| 42 | 自动选设备时 `iphone_batch` 执行到一半换了设备(拔线后换到另一台),剩下的步骤落到另一台上 | 控制的设备变了就停下报错 | 真机(batch 里放 `wait`,中途拔线) |+| 43 | Apple 键盘等配件被当成手机:`doctor` 误报 USB 上有设备,usbmuxd 被反复重启 | 只算 iPhone/iPad/iPod(厂商号 05ac 且产品名匹配) | 单测 + 真机 |+| 44 | 横屏时 WDA 掉线,HID 触摸按竖屏坐标换算,点错位置 | 每次 HID 触摸前重新截图核对横竖;横屏要有 30 秒内且匹配的 WDA 旋转角才发送,否则拒绝,不猜方向;截图和按键不受影响 | 单测(`hid_rotation_requires_fresh_matching_landscape`)+ 真机(iOS 27 横屏下让 WDA 掉线,点击落点正确;守护进程重启后横屏触摸被拒绝) |+| 45 | WDA 在横屏时就绪,记下的是横屏尺寸,之后 HID 换算错 | state.json 只存竖放尺寸和对应的 UDID,换算时再按当前方向转 | 真机(iOS 27,横屏下启动 WDA,再让它掉线后点击) |diff --git a/docs/licensing.md b/docs/licensing.mdindex ce7eecb..ed069e8 100644--- a/docs/licensing.md+++ b/docs/licensing.md@@ -16,9 +16,9 @@| plume_store(Impactor) | 账号会话存储 | MIT(Impactor 根 LICENSE) | vendor 到 `vendor/plume_store`,源码未改 | 保留版权声明(`vendor/plume_store/LICENSE-MIT-Impactor`) || omnisette(Impactor 3rdparty) | anisette 数据 | **MPL-2.0**(目录内 LICENSE;早期文档误写为 MIT,读源码后更正) | vendor 到 `vendor/omnisette`,`src/lib.rs` 加了 v3 服务地址的 getter/setter(自建 anisette 服务才能生效),其余源码未改;Cargo.toml 把本地 anisette 改成可选 feature `local-anisette`,本项目不启用,所以不编译没有许可证声明的 `android-loader`/`sysv64` 和 AGPL-3.0 的 `remove-async-await` | 同 plume_core || plume_utils(Impactor) | Bundle、Signer | MIT(Impactor 根 LICENSE) | **未 vendor**:`ictl-sign/src/bundle.rs` 改写自它的 `bundle.rs`,签名流程在 `ictl-sign/src/lib.rs` 重写 | 文件头注明来源和版权 |-| apple-codesign 0.29.0 | 代码签名 | **MPL-2.0** | vendor 到 `vendor/apple-codesign`(Impactor 打过 0o755 权限补丁的副本;去掉了上游的 tests/、docs/),经 `[patch.crates-io]` 替换 | 以 MPL-2.0 随仓库提供源码 |+| apple-codesign 0.29.0 | 代码签名 | **MPL-2.0** | vendor 到 `vendor/apple-codesign`(Impactor 打过 0o755 权限补丁的副本;去掉了上游的 tests/、docs/、src/testdata/),经 `[patch.crates-io]` 替换 | 以 MPL-2.0 随仓库提供源码 || rmcp 3.8.0 | MCP SDK | Apache-2.0(部分历史代码 MIT) | crates.io 依赖 | 保留 NOTICE/版权声明 |-| tokio、reqwest、quick-xml、image、clap、serde 等 | 通用 | MIT / Apache-2.0 | crates.io 依赖 | 保留声明:镜像里的 `/usr/share/doc/iphone-control/THIRD_PARTY_LICENSES.html` 由 cargo-about 按 Cargo.lock 生成,含许可证全文 |+| tokio、reqwest、quick-xml、image、clap、serde 等 | 通用 | MIT / Apache-2.0 | crates.io 依赖 | 保留声明:镜像里的 `/usr/share/doc/iphone-control/THIRD_PARTY_LICENSES.html` 由 cargo-about 按 Cargo.lock 生成,含许可证全文。这份清单只随镜像分发,预编译二进制的压缩包只带 `LICENSE` 和 `THIRD_PARTY.md` || WebDriverAgent(Appium) | 手机端代理 | BSD-3-Clause(Facebook 原始) | 镜像构建时下载 Appium 官方的未签名真机包(v16.15.3,校验 sha256)打成 IPA;计划改为本项目 macOS CI 编译 | 保留 BSD 声明(镜像里 `/usr/share/licenses/WebDriverAgent/LICENSE`) || usbmuxd | USB 守护进程 | **GPL-3.0**(以其 README 为准;GitHub 显示 GPL-2.0 有误) | 系统包,独立进程,不链接 | 仅"放在一起分发"。发布镜像时要提供对应源码(Debian 源码包)和许可证文本 |diff --git a/docs/tools.md b/docs/tools.mdindex 94ddea6..5f90766 100644--- a/docs/tools.md+++ b/docs/tools.md@@ -2,7 +2,7 @@The MCP server (`iphone-control mcp`) exposes 17 tools. The tool descriptions the agent sees, and every result text, are in Simplified Chinese; this page is the English reference. The definitions live in [`crates/ictl-mcp/src/lib.rs`](../crates/ictl-mcp/src/lib.rs).-Coordinates are in **points**, the same unit as the pixels of a full-screen `iphone_screenshot` (for example 430×932 on an iPhone 15 Pro Max), so an agent can read a position off a screenshot and tap it directly.+Coordinates are in **points**, the same unit as the pixels of a full-screen `iphone_screenshot` (for example 430×932 on an iPhone 15 Pro Max), so an agent can read a position off a screenshot and tap it directly. Coordinates follow the current screen orientation: after a rotation the same spot has different coordinates, so take a new screenshot. Screen sizes differ per device (an iPad mini 5 is 768×1024 in portrait); don't assume 430×932.## Looking at the screen@@ -12,6 +12,7 @@ Coordinates are in **points**, the same unit as the pixels of a full-screen `iph| `iphone_screenshot` | `x`, `y`, `width`, `height` (all optional, points) | Full screen scaled to points. With a region: cropped from the full-resolution capture and enlarged; the result says the zoom factor and how to convert back to screen points || `iphone_list_elements` | `filter` (default `""`), `limit` (default 150) | Elements that carry text: type, label, id, value, center point and size. `filter` matches type, label, name or value, case-insensitive (for example `SearchField`). Visibility is judged by position, so something hidden behind a dialog can still be listed || `iphone_wait_for` | `text`, `timeout` (seconds, default 5, max 30) | Returns as soon as an element containing `text` appears; text typed into input fields does not count. Use this instead of polling with screenshots |+| `iphone_list_apps` | `include_system` (default false) | Name and bundle id of installed apps |## Acting@@ -19,14 +20,13 @@ Coordinates are in **points**, the same unit as the pixels of a full-screen `iph|---|---|---|| `iphone_tap` | `x`, `y` | For targets without text (icons, games, maps); falls back to HID when WDA is down || `iphone_tap_element` | `text`, `index` (default 0) | Exact label or name first, then substring. If the element's center is covered (floating toolbar, keyboard, overlay), taps an uncovered part of it; if it is fully covered, does not tap and says so |-| `iphone_long_press` | `x`, `y`, `seconds` (default 1) | Holds one finger still, then lifts: context menus, home-screen quick actions, text selection |-| `iphone_swipe` | `from_x`, `from_y`, `to_x`, `to_y`, `seconds` (default 0.3) | Returns after the list has stopped scrolling (up to 2.5 s). Swipe up (`from_y` > `to_y`) to see content further down |+| `iphone_long_press` | `x`, `y`, `seconds` (default 1, max 10) | Holds one finger still, then lifts: context menus, home-screen quick actions, text selection |+| `iphone_swipe` | `from_x`, `from_y`, `to_x`, `to_y`, `seconds` (default 0.3, max 10) | Returns after the list has stopped scrolling (up to 2.5 s). Swipe up (`from_y` > `to_y`) to see content further down || `iphone_type_text` | `text`, `submit` (default false) | Types into the focused field (Chinese supported); fails if no keyboard is shown. Reads the field back afterwards: dropped trailing characters are typed again; if the field still doesn't match, it reports an error and does not press Return || `iphone_press_button` | `button`: `home`, `volume_up`, `volume_down`, `lock` | `home` refuses to act while a system alert is on screen (it would have no effect). `home` is sent as an IOHID AC Home event and waits until the home screen is in front; `lock` presses the power key over IOHID. Each falls back to the XCTest/WebDriverAgent way if it had no effect || `iphone_launch_app` | `app` (bundle id or display name, e.g. `设置`) | Cold-launches the app, or brings it back to where it was if it is already running. Waits until it is in the foreground; returns early and says so if a system alert is blocking it || `iphone_terminate_app` | `app` | Force-quits, like swiping it away in the app switcher; unsaved input is lost. No error if it wasn't running || `iphone_open_url` | `url` | Web pages open in Safari; URL schemes open their app |-| `iphone_list_apps` | `include_system` (default false) | Name and bundle id of installed apps |## Several devices@@ -37,13 +37,15 @@ Only one device is controlled at a time; every other tool acts on it. With one d| `iphone_list_devices` | — | Every iPhone/iPad on USB: name, model, iOS version, UDID; marks the one being controlled and whether it has an auto-unlock passcode || `iphone_select_device` | `device`: UDID, device name, or `auto` | Switches to that device and keeps controlling it, also after a restart. A unique substring of the name works too. `auto` goes back to automatic choice: the controlled device is kept until it disconnects. WDA has to start on the new device (10–60 s). Refused when `IPHONE_UDID` is set |-When auto-unlock is configured, action tools unlock the phone first.+## Auto-unlock and "read-only" tools++When auto-unlock is configured for the controlled device, a locked phone is unlocked first by the action tools and by `iphone_screenshot`, `iphone_list_elements` and `iphone_wait_for`. `iphone_status`, `iphone_list_apps`, `iphone_list_devices`, `iphone_select_device` and `iphone_press_button` with `lock` never unlock it. While WDA is unavailable nothing is unlocked.-Every tool carries MCP annotations: the six read-only tools (`iphone_status`, `iphone_screenshot`, `iphone_list_elements`, `iphone_list_apps`, `iphone_wait_for`, `iphone_list_devices`) are `readOnlyHint: true`; the action tools are not, and taps, long-presses, `iphone_terminate_app` and `iphone_batch` are also marked `destructiveHint: true`, since what they hit on screen can delete or send things.+Every tool carries MCP annotations: the six read-only tools (`iphone_status`, `iphone_screenshot`, `iphone_list_elements`, `iphone_list_apps`, `iphone_wait_for`, `iphone_list_devices`) are `readOnlyHint: true`. "Read-only" means they don't change what's on screen; with auto-unlock on, the three above still unlock the phone first. The action tools are not read-only, and taps, long-presses, `iphone_terminate_app` and `iphone_batch` are also marked `destructiveHint: true`, since what they hit on screen can delete or send things.-### Returning the screen after an action: `then`+## Returning the screen after an action: `then`-Screen-action tools accept the following options. `iphone_select_device` does not: use `iphone_status` after switching to check that WDA is ready.+The tools under *Acting* and `iphone_batch` accept the following options. `iphone_select_device` does not: use `iphone_status` after switching to check that WDA is ready.| Parameter | Meaning ||---|---|@@ -62,6 +64,8 @@ Without `then`, the result still warns when a system alert covers the screen, beSteps run in order. The batch stops at the first error or the first `iphone_tap_element` that finds nothing, and reports which step it stopped at. `then` applies once, after the last step. `reuse_elements: true` lets `iphone_tap_element` reuse the element tree from the last 10 seconds; use it only when the steps don't change the layout (for example pressing keys on the same keypad).+If the MCP client cancels the call, the remaining steps don't run; a request still queued for the device is dropped too. If no device was selected and the controlled device changes during a batch (for example it was unplugged and another one took over), the batch stops with an error.+```json{"steps": [@@ -73,9 +77,13 @@ Steps run in order. The batch stops at the first error or the first `iphone_tap_}```-## HID fallback in landscape+## HID fallback++Screenshots, taps, swipes and buttons fall back to CoreDevice HID only when WDA can't be reached, and only on iOS 27 or later. If a WDA request was already sent and the connection then drops or the response is incomplete, nothing is redone over HID, because the action may already have happened: the tool returns an error, and the agent should take a screenshot before trying again.++Touches over HID need the screen size. If WDA is down and the size of this device isn't known (WDA has never run on it, or the last record is for another device), the tool returns an error unless `SCREEN_W`/`SCREEN_H` are set.-On iOS 27+, HID taps and swipes convert screen coordinates back to native portrait coordinates. Before each touch, the daemon captures a fresh screenshot and checks its orientation. Landscape touches additionally require a matching WDA rotation sample from the last 30 seconds. Without one — notably after restarting the daemon — the touch is refused rather than guessed. Screenshots and hardware keys remain available.+HID taps and swipes convert screen coordinates back to native portrait coordinates. Before each touch, the daemon captures a fresh screenshot and checks its orientation. Landscape touches additionally require a matching WDA rotation sample from the last 30 seconds. Without one — notably after restarting the daemon — the touch is refused rather than guessed. Screenshots and hardware keys remain available.During a WDA outage, keep the device in the same landscape direction: both sides produce the same screenshot dimensions, so a 180° flip cannot be detected without WDA. Wait for WDA to recover before changing sides and touching again.diff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex 781c3b1..84906b0 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -15,12 +15,12 @@ The program's own messages are in Simplified Chinese; the Chinese text is quoted| State (Chinese text) | Meaning | What to do ||---|---|---|-| 手机未连接 | usbmuxd sees no phone | Check the cable and unlock the phone. Container: make sure no host `usbmuxd` is running (`sudo systemctl mask usbmuxd`). See [Phone not detected](#phone-not-detected) |+| 手机未连接 | usbmuxd sees no phone | Check the cable and unlock the phone. Container: make sure no host `usbmuxd` is running (`sudo systemctl mask usbmuxd`). With several devices, a selected device that isn't connected also shows this: check the `选设备` line of `status`, or run `select auto`. See [Phone not detected](#phone-not-detected) || 未配对 | No pairing record | Run `setup` and tap *Trust* on the phone || 开发者模式未打开 | Developer Mode is off | *Settings → Privacy & Security → Developer Mode*. The toggle only appears after the phone has been seen by a developer tool; running `setup` takes care of that |-| 手机锁屏,隧道建不起来 | The phone has not been unlocked since it restarted (BFU) | Unlock it once by hand. Auto-unlock cannot do this step |+| 手机锁屏,隧道建不起来 | The phone has not been unlocked since it restarted (BFU) | Unlock it once by hand. Auto-unlock cannot do this step. The state stays until then and the daemon keeps retrying || WDA 还没签名安装 | WebDriverAgent is not installed | Run `sign` (or `setup`) |-| 正在启动 WDA | Starting WebDriverAgent (up to about 2 minutes) | Wait. Tools that only need coordinates (tap, swipe, screenshot, buttons) already work through the HID fallback |+| 正在启动 WDA | Starting WebDriverAgent (up to about 2 minutes) | Wait. On iOS 27 and later, tools that only need coordinates (tap, swipe, screenshot, buttons) already work through the HID fallback. In landscape a touch needs a WDA orientation from the last 30 seconds and is refused otherwise; if the screen size isn't known, a touch returns an error. On older iOS, actions fail until WDA is up || WDA 卡在手机上的「Enable UI Automation」密码框 | The phone is showing *Enter iPhone passcode for "XCTest"* | Enter the passcode on the phone. This happens after a reboot, and sometimes after the daemon is restarted several times in a row. The daemon retries every 60 seconds and notifies you once || WDA 启动失败,稍后重试:… | WebDriverAgent failed for another reason | Read the error after the colon and run `doctor`. Retries back off up to 5 minutes || 就绪 | Everything works | — |@@ -36,9 +36,9 @@ The program's own messages are in Simplified Chinese; the Chinese text is quoted## WebDriverAgent won't start- **"Untrusted developer":** after the first install, trust your Apple ID under *Settings → General → VPN & Device Management* (needs internet on the phone).-- **Expired signature:** free provisioning profiles last 7 days. The daemon re-signs when fewer than `RESIGN_MIN_DAYS` (default 2) remain. `status` shows the remaining time; `resign --force` re-signs now.+- **Expired signature:** free provisioning profiles last 7 days. The daemon re-signs when fewer than `RESIGN_MIN_DAYS` (default 2) remain. `status` shows the remaining time; `resign --force` re-signs now. Automatic re-signing only covers the controlled device, and is checked within a minute after it reconnects or you switch to it. A re-sign that takes too long counts as failed and you get a notification.- **Apple ID session expired:** you get a notification, and `resign` fails with a login error. Run `login` again.-- **Developer Disk Image:** `doctor` reports whether it is mounted. Downloading needs access to GitHub; behind a firewall set `HTTP_PROXY`/`HTTPS_PROXY`, or point `ICTL_DDI_DIR` at an image extracted from Xcode.+- **Developer Disk Image:** a failure shows on the first line of `status` as `WDA 启动失败,稍后重试:开发者镜像:…`; `doctor` has no separate check for it, and the details are in `logs/daemon.log`. Downloading needs access to GitHub; behind a firewall set `HTTP_PROXY`/`HTTPS_PROXY`, or point `ICTL_DDI_DIR` at an image extracted from Xcode. With `ICTL_DDI_DIR` the daemon neither downloads nor deletes anything, and the error names any missing file. The default cache (`ddi/` in the data directory) is deleted and downloaded again after 3 failed mounts in a row.## Login and signing@@ -50,6 +50,7 @@ The program's own messages are in Simplified Chinese; the Chinese text is quoted- **The client can't connect** ("connection closed", "failed to reconnect"): restarting the container ends the MCP process; reconnect from the client (in Claude Code, run `/mcp`). Check the registered command with `iphone-control mcp-config`.- **"守护进程正忙…已放弃执行":** an action waited more than 30 seconds for the device, so it was dropped instead of tapping a screen that has changed. Take a screenshot and try again.+- **An action reports that the WDA connection dropped:** the request was already sent, so it may have happened. It is not redone over HID, to avoid tapping or typing twice. Take a screenshot before trying again.- **Taps do nothing:** a system alert may be covering the screen; the tool result says so (「屏幕上有系统弹窗…」). Dismiss it with `iphone_tap_element`. Taps right after launching an app are delayed until the launch animation is over.- **Typed text is incomplete:** `iphone_type_text` reads the field back and types missing characters again. If it still reports a mismatch, the app is rewriting the field while you type; type shorter pieces.@@ -72,4 +73,4 @@ The HID fallback keeps a screen-mirroring session open while it is in use (the D## Reporting a bug-Please include the phone model, iOS version, how you run it (container or source), and the output of `iphone-control doctor`. Remove anything private (UDID, Apple ID, notification keys) first.+Please include the iPhone or iPad model, iOS version, how you run it (Docker, prebuilt binary or source; Linux or macOS), and the output of `iphone-control doctor`. Remove anything private (UDID, Apple ID, notification keys) first.diff --git a/vendor/apple-codesign/Cargo.toml b/vendor/apple-codesign/Cargo.tomlindex 585e0fd..f77fe3e 100644--- a/vendor/apple-codesign/Cargo.toml+++ b/vendor/apple-codesign/Cargo.toml@@ -305,7 +305,7 @@ version = "1.8.1"features = ["zeroize_derive"][dependencies.zip]-version = "2.2.1"+version = "9.4.1"features = ["deflate"]default-features = false@@ -328,7 +328,7 @@ version = "0.4.43"version = "0.14.20"[dev-dependencies.zip]-version = "2.2.1"+version = "9.4.1"default-features = false[features]diff --git a/vendor/apple-codesign/src/testdata/apple-signed-3rd-party-mac.cer b/vendor/apple-codesign/src/testdata/apple-signed-3rd-party-mac.cerdeleted file mode 100644index fe5bf80..0000000Binary files a/vendor/apple-codesign/src/testdata/apple-signed-3rd-party-mac.cer and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/apple-signed-apple-development.cer b/vendor/apple-codesign/src/testdata/apple-signed-apple-development.cerdeleted file mode 100644index 7c9bdf9..0000000Binary files a/vendor/apple-codesign/src/testdata/apple-signed-apple-development.cer and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/apple-signed-apple-distribution.cer b/vendor/apple-codesign/src/testdata/apple-signed-apple-distribution.cerdeleted file mode 100644index f3a9e31..0000000Binary files a/vendor/apple-codesign/src/testdata/apple-signed-apple-distribution.cer and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/apple-signed-developer-id-application.cer b/vendor/apple-codesign/src/testdata/apple-signed-developer-id-application.cerdeleted file mode 100644index dca1bfc..0000000Binary files a/vendor/apple-codesign/src/testdata/apple-signed-developer-id-application.cer and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/apple-signed-developer-id-installer.cer b/vendor/apple-codesign/src/testdata/apple-signed-developer-id-installer.cerdeleted file mode 100644index 6a2de5f..0000000Binary files a/vendor/apple-codesign/src/testdata/apple-signed-developer-id-installer.cer and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/ed25519.pk8 b/vendor/apple-codesign/src/testdata/ed25519.pk8deleted file mode 100644index b7ffa38..0000000Binary files a/vendor/apple-codesign/src/testdata/ed25519.pk8 and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/rsa-2048.pk8 b/vendor/apple-codesign/src/testdata/rsa-2048.pk8deleted file mode 100644index 1a1ec9c..0000000Binary files a/vendor/apple-codesign/src/testdata/rsa-2048.pk8 and /dev/null differdiff --git a/vendor/apple-codesign/src/testdata/secp256r1.pk8 b/vendor/apple-codesign/src/testdata/secp256r1.pk8deleted file mode 100644index a696170..0000000Binary files a/vendor/apple-codesign/src/testdata/secp256r1.pk8 and /dev/null differdiff --git a/website/.vitepress/config.mts b/website/.vitepress/config.mtsindex 8c21912..48d9dbb 100644--- a/website/.vitepress/config.mts+++ b/website/.vitepress/config.mts@@ -36,6 +36,8 @@ export default defineConfig({text: '使用',items: [{ text: '配置', link: '/guide/configuration' },+ { text: '命令行', link: '/guide/cli' },+ { text: '多台设备', link: '/guide/multi-device' },{ text: '通知', link: '/guide/notifications' },{ text: '自动解锁', link: '/guide/auto-unlock' },{ text: '安全与隐私', link: '/guide/security' },@@ -99,6 +101,8 @@ export default defineConfig({text: 'Usage',items: [{ text: 'Configuration', link: '/en/guide/configuration' },+ { text: 'CLI', link: '/en/guide/cli' },+ { text: 'Several Devices', link: '/en/guide/multi-device' },{ text: 'Notifications', link: '/en/guide/notifications' },{ text: 'Auto-unlock', link: '/en/guide/auto-unlock' },{ text: 'Security and Privacy', link: '/en/guide/security' },diff --git a/website/deploy/backup.md b/website/deploy/backup.mdindex 97ba08e..6580838 100644--- a/website/deploy/backup.md+++ b/website/deploy/backup.md@@ -9,8 +9,8 @@| `wda/` | 签好的 WebDriverAgent | 自动重签 || `ddi/` | 开发者镜像缓存 | 自动重新下载 || `secrets/passcodes/` | 各设备的锁屏密码(仅开启自动解锁时) | 要重新 `passcode set` |-| `state.json` | 状态快照、上次重签结果 | 自动重建 |-| `logs/` | 日志 | — |+| `state.json` | 签好的 WDA 包信息(Team ID、Bundle ID、描述文件到期时间)、选定的设备、最近一台设备的屏幕尺寸、上次重签结果 | 守护进程按「WDA 还没签名」启动:要重新 `sign` 或 `setup`,选过设备的要重新 `select` |+| `logs/` | 日志、自动解锁的停用标记 `UNLOCK-DISABLED` | 日志没了不要紧。但停用标记没了就撤销了这层保护:之前输错过的话,可能再用同一个错误密码输一遍 |位置:Docker 部署是仓库目录下的 `./data`(root 所有,权限 0700);从源码运行是 `~/.local/share/iphone-control`,配对记录在系统的 `/var/lib/lockdown`;macOS 上数据目录也是 `~/.local/share/iphone-control`,配对记录由系统保存在 `/var/db/lockdown`(和 Finder 共用)。diff --git a/website/deploy/docker.md b/website/deploy/docker.mdindex a11d38a..5a656f2 100644--- a/website/deploy/docker.md+++ b/website/deploy/docker.md@@ -13,7 +13,7 @@```yamlservices:iphone:- image: ghcr.io/derrors/iphone-control:latest # 或固定版本,例如 :0.1.0+ image: ghcr.io/derrors/iphone-control:latest # 或固定版本,例如 :0.1.3container_name: iphone-control# 只开放 USB 字符设备,不需要 privilegeddevice_cgroup_rules:@@ -54,10 +54,10 @@ docker compose up -d --build### 用预构建镜像-发布正式版本后,镜像在 `ghcr.io/derrors/iphone-control`(amd64、arm64)。在 `.env` 里设:+镜像在 `ghcr.io/derrors/iphone-control`(amd64、arm64)。在 `.env` 里设:```ini-IMAGE=ghcr.io/derrors/iphone-control:latest # 或固定版本,例如 :0.1.0+IMAGE=ghcr.io/derrors/iphone-control:latest # 或固定版本,例如 :0.1.3```然后:@@ -77,6 +77,8 @@ docker compose pull && docker compose up -d --no-build## 升级+升级前先看[更新日志](https://github.com/Derrors/iphone-control/blob/main/CHANGELOG.zh-CN.md)里的升级注意事项。+```bashdocker compose pull && docker compose up -d # 只写 compose 文件# 或diff --git a/website/deploy/macos.md b/website/deploy/macos.mdindex 6c607e1..fa3763e 100644--- a/website/deploy/macos.md+++ b/website/deploy/macos.md@@ -3,14 +3,14 @@iphone-control 也能直接跑在 Mac 上:用 macOS 自带的 usbmuxd,不需要 Xcode,也不需要付费开发者账号。和 Linux 上从源码运行基本一样,区别见文末的[已知差异](#已知差异)。::: info 验证情况-已在 MacBook Pro(Apple M3 Pro)/ macOS 26.6.2 + iPhone 15 Pro Max / iOS 27.0.1 上完整验证:安装向导、全部 MCP 工具、开着 Finder 连续操作、同一条隧道连续 30 分钟、拔插和手机重启后自动恢复。Intel Mac 还没测过。验证步骤和结果见 [macOS 真机验证](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md)。+已在 MacBook Pro(Apple M3 Pro)/ macOS 26.6.2 + iPhone 15 Pro Max / iOS 27.0.1 上验证:安装向导、当时的全部 MCP 工具、开着 Finder 连续操作、同一条隧道连续 30 分钟、拔插和手机重启后自动恢复。这次验证早于 0.1.3,多设备工具(`iphone_list_devices`、`iphone_select_device`)没有在 macOS 上验证过。Intel Mac 还没测过。验证步骤和结果见 [macOS 真机验证](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md)。:::## 需要- Apple Silicon 的 Mac- 用预编译二进制什么都不用装;从源码编译要 Xcode 命令行工具和 Rust 1.88 以上。都**不需要**完整的 Xcode-- 一部 iOS 17 以上的 iPhone,用能**传数据**的线连接+- 一部 iOS 17 以上的 iPhone 或 iPad,用能**传数据**的线连接- 一个免费 Apple ID(建议专门注册一个)::: warning 不能用 Docker@@ -128,6 +128,8 @@ sudo launchctl kickstart -k system/com.apple.usbmuxd## 升级+升级前先看[更新日志](https://github.com/Derrors/iphone-control/blob/main/CHANGELOG.zh-CN.md)里的升级注意事项。+预编译二进制:按「安装」一节下载新版本,覆盖 `~/.local/bin/iphone-control`。从源码编译:```bash@@ -160,4 +162,4 @@ rm -rf ~/.local/share/iphone-control ~/.config/iphone-control # 会删掉 Appl| 配对记录 | `/var/lib/lockdown` | `/var/db/lockdown`(和 Finder 共用) || Docker | 支持 | 不支持 |-还没在 Mac 上验证过的:Xcode 的「设备与模拟器」窗口开着时会不会抢连接、手机第一次在这台 Mac 上配对的流程、Intel Mac。遇到问题欢迎[反馈](https://github.com/Derrors/iphone-control/issues)。+还没在 Mac 上验证过的:Xcode 的「设备与模拟器」窗口开着时会不会抢连接、手机第一次在这台 Mac 上配对的流程、iPad、接多台设备、Intel Mac。遇到问题欢迎[反馈](https://github.com/Derrors/iphone-control/issues)。diff --git a/website/deploy/source.md b/website/deploy/source.mdindex 19010d8..4d9cf1c 100644--- a/website/deploy/source.md+++ b/website/deploy/source.md@@ -6,7 +6,7 @@### 预编译二进制-发布正式版本后,[Releases](https://github.com/Derrors/iphone-control/releases) 里有 Linux x86_64 和 aarch64 的压缩包(需要 glibc 2.34 以上:Debian 12、Ubuntu 22.04 及更新的发行版):+[Releases](https://github.com/Derrors/iphone-control/releases) 里有 Linux x86_64 和 aarch64 的压缩包(需要 glibc 2.34 以上:Debian 12、Ubuntu 22.04 及更新的发行版):```bashsudo apt install usbmuxd@@ -66,6 +66,8 @@ loginctl enable-linger "$USER" # 不登录也随开机启动## 升级+升级前先看[更新日志](https://github.com/Derrors/iphone-control/blob/main/CHANGELOG.zh-CN.md)里的升级注意事项。+```bashgit pull && cargo install --path apps/iphone-control --locked # 或换上新版本的二进制systemctl --user restart iphone-controldiff --git a/website/en/deploy/backup.md b/website/en/deploy/backup.mdindex 04197c3..b93ebf3 100644--- a/website/en/deploy/backup.md+++ b/website/en/deploy/backup.md@@ -9,8 +9,8 @@| `wda/` | Signed WebDriverAgent | Re-signed automatically || `ddi/` | Developer Disk Image cache | Downloaded again || `secrets/passcodes/` | Per-device passcodes (only with auto-unlock) | Run `passcode set` again |-| `state.json` | State snapshot, last signing result | Rebuilt automatically |-| `logs/` | Logs | — |+| `state.json` | Signed WDA details (Team ID, bundle id, profile expiry), selected device, screen size of the most recent device, last signing result | The daemon starts as if WDA isn't signed: run `sign` or `setup` again, and `select` again if you had selected a device |+| `logs/` | Logs, auto-unlock's stop marker `UNLOCK-DISABLED` | The logs don't matter. Losing the marker removes a safeguard: after a wrong passcode, the same one could be entered again |Location: `./data` in the repository directory for Docker (owned by root, mode 0700); `~/.local/share/iphone-control` for a source install, with pairing records in the system's `/var/lib/lockdown`. On macOS the data directory is also `~/.local/share/iphone-control`, and the system keeps pairing records in `/var/db/lockdown` (shared with Finder).diff --git a/website/en/deploy/docker.md b/website/en/deploy/docker.mdindex 86352ce..273853d 100644--- a/website/en/deploy/docker.md+++ b/website/en/deploy/docker.md@@ -13,7 +13,7 @@ No need to clone the repository — the least effort. Create a directory (e.g. ````yamlservices:iphone:- image: ghcr.io/derrors/iphone-control:latest # or pin a version, e.g. :0.1.0+ image: ghcr.io/derrors/iphone-control:latest # or pin a version, e.g. :0.1.3container_name: iphone-control# USB character devices only; no privileged neededdevice_cgroup_rules:@@ -54,10 +54,10 @@ docker compose up -d --build### Use the prebuilt image-After a release, images are published at `ghcr.io/derrors/iphone-control` (amd64, arm64). In `.env`:+Images are published at `ghcr.io/derrors/iphone-control` (amd64, arm64). In `.env`:```ini-IMAGE=ghcr.io/derrors/iphone-control:latest # or pin a version, e.g. :0.1.0+IMAGE=ghcr.io/derrors/iphone-control:latest # or pin a version, e.g. :0.1.3```Then:@@ -77,6 +77,8 @@ Afterwards, run the [setup wizard](../guide/getting-started) once.## Upgrade+Read the upgrade notes in the [changelog](https://github.com/Derrors/iphone-control/blob/main/CHANGELOG.md) first.+```bashdocker compose pull && docker compose up -d # just a compose file# ordiff --git a/website/en/deploy/macos.md b/website/en/deploy/macos.mdindex 91e7f4b..a093caf 100644--- a/website/en/deploy/macos.md+++ b/website/en/deploy/macos.md@@ -3,14 +3,14 @@iphone-control also runs directly on a Mac, using the usbmuxd that ships with macOS. No Xcode and no paid developer account. It works like a source install on Linux; the differences are listed under [Known differences](#known-differences).::: info Verified-Fully verified on a MacBook Pro (Apple M3 Pro) / macOS 26.6.2 with an iPhone 15 Pro Max / iOS 27.0.1: the setup wizard, every MCP tool, continuous use with Finder open, one tunnel kept busy for 30 minutes, and recovery after unplugging and phone reboots. Intel Macs are untested. Steps and results: [macOS verification](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md) (in Chinese).+Verified on a MacBook Pro (Apple M3 Pro) / macOS 26.6.2 with an iPhone 15 Pro Max / iOS 27.0.1: the setup wizard, every MCP tool at that time, continuous use with Finder open, one tunnel kept busy for 30 minutes, and recovery after unplugging and phone reboots. This predates 0.1.3: the multi-device tools (`iphone_list_devices`, `iphone_select_device`) haven't been verified on macOS. Intel Macs are untested. Steps and results: [macOS verification](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md) (in Chinese).:::## You need- An Apple Silicon Mac- Nothing else for the prebuilt binary; to build from source, the Xcode Command Line Tools and Rust 1.88+. Full Xcode is **not** needed-- An iPhone on iOS 17+, connected with a cable that carries **data**+- An iPhone or iPad on iOS 17+, connected with a cable that carries **data**- A free Apple ID (a dedicated one is recommended)::: warning No Docker@@ -128,6 +128,8 @@ sudo launchctl kickstart -k system/com.apple.usbmuxd## Upgrade+Read the upgrade notes in the [changelog](https://github.com/Derrors/iphone-control/blob/main/CHANGELOG.md) first.+Prebuilt binary: download the new version as under *Install* and replace `~/.local/bin/iphone-control`. From source:```bash@@ -160,4 +162,4 @@ On the phone, delete the WebDriverAgent app; its profile under *VPN & Device Man| Pairing records | `/var/lib/lockdown` | `/var/db/lockdown` (shared with Finder) || Docker | Supported | Not supported |-Not yet verified on a Mac: whether Xcode's *Devices and Simulators* window competes for the connection, pairing a phone with the Mac for the first time, and Intel Macs. [Reports](https://github.com/Derrors/iphone-control/issues) are welcome.+Not yet verified on a Mac: whether Xcode's *Devices and Simulators* window competes for the connection, pairing a phone with the Mac for the first time, iPads, several devices, and Intel Macs. [Reports](https://github.com/Derrors/iphone-control/issues) are welcome.diff --git a/website/en/deploy/source.md b/website/en/deploy/source.mdindex b271ec7..740acac 100644--- a/website/en/deploy/source.md+++ b/website/en/deploy/source.md@@ -6,7 +6,7 @@ Run it directly as a regular user on Linux, without Docker. You need the system### Prebuilt binary-After a release, [Releases](https://github.com/Derrors/iphone-control/releases) has Linux x86_64 and aarch64 archives (glibc 2.34 or later: Debian 12, Ubuntu 22.04 and newer):+[Releases](https://github.com/Derrors/iphone-control/releases) has Linux x86_64 and aarch64 archives (glibc 2.34 or later: Debian 12, Ubuntu 22.04 and newer):```bashsudo apt install usbmuxd@@ -66,6 +66,8 @@ loginctl enable-linger "$USER" # start at boot without logging## Upgrade+Read the upgrade notes in the [changelog](https://github.com/Derrors/iphone-control/blob/main/CHANGELOG.md) first.+```bashgit pull && cargo install --path apps/iphone-control --locked # or drop in the new binarysystemctl --user restart iphone-controldiff --git a/website/en/guide/auto-unlock.md b/website/en/guide/auto-unlock.mdindex 2a05b70..29ba52a 100644--- a/website/en/guide/auto-unlock.md+++ b/website/en/guide/auto-unlock.md@@ -1,6 +1,6 @@# Auto-unlock-Off by default. When enabled, MCP actions unlock the phone with your saved passcode if it is locked.+Off by default. When enabled, MCP actions unlock the phone with your saved passcode if it is locked, and so do the read-only screenshot, element-list and `iphone_wait_for` tools. Nothing is unlocked while WDA is unavailable.::: danger Understand the risk firstThe passcode is stored **in plain text** in the data directory. Anyone who can log in to the host, read backups of the data directory, or call this MCP server can unlock your phone. Only enable it on a host you fully control, preferably with a phone dedicated to automation.@@ -15,7 +15,8 @@ docker exec -it iphone-control iphone-control passcode setThe passcode is saved for the device the daemon is controlling; for another one add `--device <UDID or name>`. Numeric passcodes of 4 or more digits only. To disable:```bash-docker exec -it iphone-control iphone-control passcode clear+docker exec -it iphone-control iphone-control passcode clear # the controlled device; --device for another+docker exec -it iphone-control iphone-control passcode clear --all # all devices```## Several devices@@ -28,18 +29,22 @@ Older versions kept a single passcode (`secrets/passcode`) without knowing which- After every digit it checks how many digits the passcode field shows and stops at once if they don't match (an incomplete entry is not a wrong attempt); only a first digit that didn't register is retried, up to 3 rounds.- If the phone is still locked after the full passcode, auto-unlock is **disabled immediately** and you are notified. It never tries a second time, so it can't pile up wrong attempts and trigger data erasure.+- From the second digit on, a stop marker is written first (`logs/UNLOCK-DISABLED` in the data directory) and removed only once the phone is confirmed unlocked or the entry is confirmed incomplete. So an error during entry, or the process being killed, also leaves auto-unlock disabled.+- The marker is **global**: a failure on one device disables auto-unlock on all of them.- The first unlock after a reboot (BFU) always needs a person.- A phone charging on its side goes into **StandBy**, which doesn't bring up the passcode keypad, so auto-unlock fails. Turn it off under *Settings → StandBy* when you use auto-unlock.## Re-enable after it was disabled-If it was disabled because the passcode was wrong (for example, you changed it), save the new one and reset:+Unlock the phone by hand first. If the passcode was wrong (for example, you changed it), save the new one and reset:```bashdocker exec -it iphone-control iphone-control passcode setdocker exec -it iphone-control iphone-control unlock-reset```+If it stopped because of an error during entry or a killed process, the passcode may be fine; once you've checked, `unlock-reset` alone is enough. `unlock-reset` doesn't check the passcode, and `passcode set` and `passcode clear` don't lift the stop. Don't delete `logs/` to get going again: that removes this safeguard.+::: tip Don't need auto-unlock?Set *Settings → Display & Brightness → Auto-Lock* to *Never* on the phone, and it won't lock by itself.:::diff --git a/website/en/guide/cli.md b/website/en/guide/cli.mdnew file mode 100644index 0000000..bce1376--- /dev/null+++ b/website/en/guide/cli.md@@ -0,0 +1,71 @@+# CLI++Every command is `iphone-control <command>`. With Docker, prefix it with `docker exec -it iphone-control`; for a source install and on macOS, run it directly. `--help` shows help, `--version` the version. Output is in Simplified Chinese.++## Global options++These go before the command, for example `iphone-control --socket /path/ctl.sock mcp`.++| Option | Environment variable | Meaning |+|---|---|---|+| `--data-dir <dir>` | `ICTL_DATA_DIR` | Data directory; defaults in [Configuration](./configuration#directories-and-control-socket) |+| `--socket <path>` | `ICTL_SOCKET` | The daemon's control socket; defaults in the same place |++## Running++| Command | What it does |+|---|---|+| `daemon` | The long-running daemon. The container's entry point; for a source install it's started by systemd or by hand, and on macOS you run it in a terminal |+| `mcp` | MCP stdio server, started by the AI client |+| `mcp-config [--container <name>]` | Prints the command that registers the MCP server with Claude Code. Inside a container or with `--container` it uses `docker exec`; otherwise it calls this binary directly |++## Setup and signing++| Command | What it does |+|---|---|+| `setup` | Setup wizard: pairing, Developer Mode, Apple ID sign-in, signing and installing WDA. Safe to re-run; only acts on the controlled device |+| `login [email]` | Sign in to the Apple ID. The password and code are only typed here; without an email it asks for one |+| `sign` | Sign and install WDA now, same as `resign --force`. Registers the device with the Apple ID |+| `resign [--force]` | Re-sign only when fewer than `RESIGN_MIN_DAYS` days remain; `--force` re-signs now. Without `--force` it doesn't register a device that has never had WDA |++## Checking state++| Command | What it does |+|---|---|+| `status` | State, phone, how the device was chosen, time left on the profile, auto-unlock, notifications, recent log |+| `doctor` | Layer-by-layer checks with a fix for each failure |++## Several devices++See [Several Devices](./multi-device).++| Command | What it does |+|---|---|+| `devices` | Lists devices on USB; marks the controlled one and whether it has an auto-unlock passcode |+| `select <UDID\|name\|auto>` | Control another device, remembered across restarts; `auto` goes back to automatic choice |++## Auto-unlock++See [Auto-unlock](./auto-unlock). `--device` takes a UDID or name, and the device must be connected; without it, the controlled device is used.++| Command | What it does |+|---|---|+| `passcode set [--device <device>]` | Save this device's passcode and turn auto-unlock on |+| `passcode clear [--device <device>]` | Delete this device's passcode |+| `passcode clear --all` | Delete every device's passcode |+| `unlock-reset` | Turn auto-unlock back on after it was disabled. It doesn't check the passcode, so make sure it's right first |++## Other++| Command | What it does |+|---|---|+| `notify-test [event]` | Send test notifications: one per event type, or one type (`resign`, `session`, `pin`, `pin-recovered`, `unlock`, `offline`, `online`) |+| `wda-bridge [--port <port>]` | Expose WDA on `127.0.0.1` (default port 8100) for other tools. WDA has no authentication and every local user can reach it, so stop it when done |++The `debug` subcommand for diagnostics isn't compiled by default; see the [contributing guide](https://github.com/Derrors/iphone-control/blob/main/CONTRIBUTING.md#testing-on-a-real-phone).++## Notes++- **Need the daemon running:** `setup`, `status`, `doctor`, `sign`, `resign`, `devices`, `select`, `unlock-reset`, and MCP tool calls.+- **Need an interactive terminal:** `setup`, `login`, `passcode set`; use `-it` with Docker.+- **Environment variables:** the CLI reads the environment of the current shell. For a source install and on macOS, only the daemon loads `~/.config/iphone-control/env`; before `login`, `setup` (if you set `ICTL_ANISETTE_URL`) or `notify-test`, run `set -a; . ~/.config/iphone-control/env; set +a`.diff --git a/website/en/guide/configuration.md b/website/en/guide/configuration.mdindex 27f3649..3df6f34 100644--- a/website/en/guide/configuration.md+++ b/website/en/guide/configuration.md@@ -14,7 +14,7 @@ Everything is configured with environment variables, and all of them are optiona| `HTTP_PROXY` / `HTTPS_PROXY` | direct | Proxy for Apple, anisette, Developer Disk Image and notification traffic || `IPHONE_UDID` | automatic | Pin the device to control. Unset: the controlled device is kept until it disconnects, and you can switch with the `select` command or the `iphone_select_device` tool. When set, switching is refused || `RESIGN_MIN_DAYS` | `2` | Re-sign when fewer days than this remain |-| `RESIGN_CHECK_HOURS` | `6` | How often to check |+| `RESIGN_CHECK_HOURS` | `6` | How often to check; it is also checked within a minute after the phone reconnects or you switch devices || `OFFLINE_ALERT_MIN` | `10` | Notify after the phone has been offline this many minutes; `0` disables |Notification variables: see [Notifications](./notifications).@@ -24,11 +24,24 @@ Notification variables: see [Notifications](./notifications).| Variable | Meaning ||---|---|| `ICTL_ANISETTE_URL` | Your own anisette server (the default is a public third-party one; see [Security](./security)) |-| `ICTL_DDI_URL` / `ICTL_DDI_DIR` | Developer Disk Image download URL / local directory (extracted from Xcode) |-| `ICTL_MANAGE_USBMUXD` | Set to `0` when the host already runs usbmuxd, so the daemon doesn't start its own |-| `SCREEN_W` / `SCREEN_H` | Screen size in points for the HID fallback before WDA has ever connected |+| `ICTL_DDI_URL` | Developer Disk Image download URL; the default is a community-maintained mirror |+| `ICTL_DDI_DIR` | A Developer Disk Image directory you extracted from Xcode. The daemon doesn't download anything or delete its files, and the error names any missing file. When unset, the `ddi/` cache in the data directory is used, and it is deleted and downloaded again after 3 failed mounts in a row |+| `ICTL_MANAGE_USBMUXD` | Whether the daemon starts its own usbmuxd. Default: yes as root (container), no as a regular user, which uses the system one. `0` or `false` turns it off, for example as root on a host that already runs a usbmuxd service |+| `ICTL_USBMUXD_BIN` | The executable the daemon runs when it starts usbmuxd itself; default `usbmuxd` |+| `ICTL_WDA_UNSIGNED` | Path of the unsigned WDA. Default: `/usr/share/iphone-control/WDA-unsigned.ipa` in the image; without an image (source install), `wda/WDA-unsigned.ipa` in the data directory, downloaded before the first signing. A path you set yourself is not downloaded |+| `SCREEN_W` / `SCREEN_H` | Screen size in points for the HID fallback, used only while WDA is down and there is no record of this device's size: WDA has never connected, or you switched to a device without one. It applies to every device, so take care with several || `ICTL_LOG` | Log filter, e.g. `info,ictl_wda::http=debug` logs every WDA request with its duration |+## Directories and control socket++You normally leave these alone, and shouldn't change them with Docker (the container fixes `ICTL_DATA_DIR`, where the data volume is mounted). If you do set them, don't leave them empty, and give the daemon, the CLI and the MCP server the same values: outside a container only the daemon reads the settings file; see [Source / Binary](../deploy/source#run).++| Variable | Default | Meaning |+|---|---|---|+| `ICTL_DATA_DIR` | root: `/var/lib/iphone-control`<br>regular user: `$XDG_DATA_HOME/iphone-control`, or `~/.local/share/iphone-control` if unset | Data directory; same as the CLI's `--data-dir` |+| `ICTL_SOCKET` | root: `/run/iphone-control/ctl.sock`<br>regular user: `$XDG_RUNTIME_DIR/iphone-control/ctl.sock`, or in the data directory without that variable (macOS) | The daemon's control socket; same as the CLI's `--socket` |+| `XDG_DATA_HOME` / `XDG_RUNTIME_DIR` | set by the system | Not this project's variables; they only change the two defaults above for a regular user |+## Docker Compose onlyThese apply to the repository's own `compose.yaml`; in a compose file you wrote yourself, edit `container_name`, `image` and `volumes` directly.diff --git a/website/en/guide/getting-started.md b/website/en/guide/getting-started.mdindex 91c261b..96c4221 100644--- a/website/en/guide/getting-started.md+++ b/website/en/guide/getting-started.md@@ -5,7 +5,7 @@ Deploying with Docker on Linux takes about 15 minutes. Without Docker, see [Sour## You need- A Linux host with Docker (including Compose v2)-- An iPhone (iOS 17+) and a cable that carries data+- An iPhone or iPad (iOS 17+) and a cable that carries data- A free Apple ID (a dedicated one is recommended)- Internet access to Apple and GitHub from the host (set a proxy if needed)@@ -21,7 +21,7 @@ cp .env.example .env # set HTTP_PROXY / HTTPS_PROXY here if you need a prdocker compose up -d --build```-The first build compiles Rust and takes a few minutes. After a release you can use the prebuilt image instead; see [Docker](../deploy/docker).+The first build compiles Rust and takes a few minutes. You can also use the prebuilt image instead; see [Docker](../deploy/docker).## 2. Run the setup wizarddiff --git a/website/en/guide/multi-device.md b/website/en/guide/multi-device.mdnew file mode 100644index 0000000..23053c8--- /dev/null+++ b/website/en/guide/multi-device.md@@ -0,0 +1,66 @@+# Several Devices++A host can have several iPhones and iPads connected, but it controls one at a time: every tool and command acts on that one. With a single device you can skip this page.++With Docker, prefix the commands below with `docker exec -it iphone-control`. Don't run two copies of iphone-control, or other usbmuxd-based tools, against the same device.++## List and switch++```bash+iphone-control devices # connected devices; marks the controlled one and whether it has an auto-unlock passcode+iphone-control select <UDID or name> # control this one+iphone-control select auto # back to automatic choice+```++Agents use `iphone_list_devices` and `iphone_select_device`, which do the same.++- Only devices connected over USB can be selected. It tries the UDID, then the device name, then a part of the name that matches exactly one device. If it matches several, you get an error and need the UDID.+- WDA takes 10–60 seconds to start after switching; check with `status` (or `iphone_status`) that it's ready. A device that has never had WDA needs [installing](#install-on-a-new-device) first.++## Which device is controlled++| Priority | Source | Behaviour |+|---|---|---|+| 1 | The `IPHONE_UDID` environment variable | Pins this device; `select` can't switch away |+| 2 | Selected with `select` or `iphone_select_device` | Saved in `state.json`, so it survives a restart |+| 3 | Automatic (nothing selected, or `select auto`) | The controlled device is kept until it disconnects, then another connected one takes over |++**When the selected device isn't connected**, the state is 手机未连接 (phone not connected). It does not switch to another device, so actions and auto-unlock can't land on the wrong one. After `OFFLINE_ALERT_MIN` minutes you also get an offline notification. The `选设备` line of `status` shows which device is selected, and `select auto` goes back to automatic choice.++**With automatic choice**, if the controlled device changes during an `iphone_batch` (for example it was unplugged and another took over), the batch stops with an error.++## Install on a new device++```bash+iphone-control select <new device>+iphone-control setup+```++`setup` only acts on the controlled device, so `select` first. It registers the device with your Apple ID, which uses up one of the account's device slots. Automatic re-signing doesn't register a device that has never had WDA; `doctor` tells you to run `setup` in that case.++## Re-signing++Automatic re-signing only covers the controlled device. An idle device's profile expires after 7 days. Within a minute of switching back, it is checked and re-signed if it has expired or is about to; you can also run `resign --force`.++## Auto-unlock++Passcodes are kept per device:++```bash+iphone-control passcode set --device <UDID or name> # the device must be connected+```++The stop marker is global: if auto-unlock fails on one device, it stops on all of them until you run `unlock-reset`. See [Auto-unlock](./auto-unlock).++## Notifications++Notifications don't name the device. Use `status` or `devices` to see which one it is.++## iPad differences++- **Touch ID models:** swiping up on the lock screen shows a Touch ID prompt, and the keypad only appears after tapping *Use Passcode*. The daemon does that itself during auto-unlock.+- **Landscape:** coordinates follow the current orientation, and auto-unlock and the HID fallback convert them back to the device's native orientation. For the HID fallback's landscape limits, see [Tools](./tools#when-wda-is-down-the-hid-fallback).+- **No HID fallback on iOS 26:** actions fail while WDA restarts, the same as on an iPhone.+- **The screen isn't 430×932:** an iPad mini 5 is 768×1024 in portrait. Go by the screenshot and `iphone_status`.++Verified on: iPad mini 5, iOS 26.6.1 (Linux, Docker).diff --git a/website/en/guide/notifications.md b/website/en/guide/notifications.mdindex 7b36c29..8ab4047 100644--- a/website/en/guide/notifications.md+++ b/website/en/guide/notifications.md@@ -13,7 +13,14 @@ The daemon notifies you when the phone needs attention, through whichever channe| Auto-unlock failed and was disabled | See [Auto-unlock](./auto-unlock) || Phone offline / back online | Check the cable and the host |-The same event isn't sent twice; recovery is sent once.+How repeats are limited:++- Re-signing failed, Apple ID session expired: not repeated for 20 hours; sent again after that if the problem is still there.+- Passcode needed, phone offline: sent once until it recovers. Only these two have a recovery notification ("WDA recovered", "back online").+- Auto-unlock disabled: sent once; it can only be sent again after `unlock-reset`.+- This record is kept in memory only. Restarting the daemon clears it, so a problem that isn't solved yet is sent again.++Notifications don't name the device; with several connected, use `status` to see which one. See [Several devices](./multi-device).## Barkdiff --git a/website/en/guide/tools.md b/website/en/guide/tools.mdindex 2d5da9e..31f6d29 100644--- a/website/en/guide/tools.md+++ b/website/en/guide/tools.md@@ -1,6 +1,6 @@# Tools-The MCP server provides 17 tools. Coordinates are in **points**, matching the pixels of a full-screen screenshot (430×932 on an iPhone 15 Pro Max), so the agent can tap what it reads off a screenshot.+The MCP server provides 17 tools. Coordinates are in **points**, matching the pixels of a full-screen screenshot (430×932 on an iPhone 15 Pro Max), so the agent can tap what it reads off a screenshot. Coordinates follow the screen orientation: after a rotation the same spot has different coordinates, so take a new screenshot. Screen sizes differ per device; an iPad mini 5 is 768×1024 in portrait.## Looking at the screen@@ -9,7 +9,10 @@ The MCP server provides 17 tools. Coordinates are in **points**, matching the pi| `iphone_status` | WDA ready or not, locked or not, foreground app, screen size || `iphone_screenshot` | Screenshot; with `x`, `y`, `width`, `height` it returns an enlarged region for small text and icons || `iphone_list_elements` | Elements with text: type, text, center, size; `filter` by text or type |-| `iphone_wait_for` | Wait until some text appears (page loaded, dialog shown); text inside input fields doesn't count |+| `iphone_wait_for` | Wait until some text appears (page loaded, dialog shown); text inside input fields doesn't count. `timeout` defaults to 5 seconds, max 30 |+| `iphone_list_apps` | Installed apps; read-only, no `then` |++With [auto-unlock](./auto-unlock) on, `iphone_screenshot`, `iphone_list_elements` and `iphone_wait_for` also unlock a locked phone first. They are marked read-only because they don't change what's on screen. `iphone_status` and `iphone_list_apps` don't unlock it.## Acting@@ -17,14 +20,13 @@ The MCP server provides 17 tools. Coordinates are in **points**, matching the pi|---|---|| `iphone_tap` | Tap coordinates || `iphone_tap_element` | Tap by text; if the center is covered by a floating bar or the keyboard it taps a visible part, and if it's fully covered it doesn't tap |-| `iphone_long_press` | Long press |-| `iphone_swipe` | Swipe; returns once the list has stopped scrolling |+| `iphone_long_press` | Long press; `seconds` defaults to 1, max 10 |+| `iphone_swipe` | Swipe; returns once the list has stopped scrolling. `seconds` defaults to 0.3, max 10 || `iphone_type_text` | Type into the focused field (Chinese supported), read it back and fix dropped characters; `submit` presses Return || `iphone_press_button` | `home`, `volume_up`, `volume_down`, `lock` || `iphone_launch_app` / `iphone_terminate_app` | Launch / quit an app by name (e.g. `设置`) or bundle id || `iphone_open_url` | Open a link or URL scheme |-| `iphone_list_apps` | Installed apps |-| `iphone_batch` | Run up to 20 steps in one call, stopping at the first error |+| `iphone_batch` | Run up to 20 steps in one call, stopping at the first error. If the MCP client cancels the call, the remaining steps don't run; with no device selected, it also stops with an error if the controlled device changes |## Several devices@@ -35,9 +37,11 @@ Only one device is controlled at a time; every other tool acts on it. With one d| `iphone_list_devices` | Every iPhone/iPad on USB: name, model, iOS version, UDID; marks the one being controlled and whether it has an auto-unlock passcode || `iphone_select_device` | Switch to another device (UDID or name), remembered across restarts; `auto` goes back to automatic choice. WDA takes 10–60 s to start on the new device. Not possible when `IPHONE_UDID` is set |+Details: [Several devices](./multi-device).+## See the screen after an action: `then`-Every action tool accepts `then`: it waits for the screen to settle and returns it, saving a round trip.+The tools under *Acting* accept `then`: it waits for the screen to settle and returns it, saving a round trip.| Parameter | Meaning ||---|---|@@ -48,4 +52,13 @@ Every action tool accepts `then`: it waits for the screen to settle and returnsThe result says how long it waited, whether the page is probably still loading, and whether a dialog is in the way. Even without `then`, it warns when a system alert covers the screen.+## When WDA is down: the HID fallback++When WDA can't be reached, screenshots, taps, swipes and buttons go through CoreDevice HID, with these limits:++- It needs iOS 27 or later. Older iOS has no such path, and actions fail while WDA restarts.+- **Landscape:** before each touch the screen is captured again to check its orientation, and the daemon also needs a matching orientation from WDA in the last 30 seconds. Without one, for example right after a daemon restart, the touch is refused rather than guessed. Screenshots and buttons still work. Don't flip the device to the other side during an outage; wait for WDA to recover first.+- **Screen size:** while WDA is down, taps and swipes return an error if there is no record of this device's size. Wait for WDA to come up once, or set [`SCREEN_W`/`SCREEN_H`](./configuration#advanced).+- **No redo:** if a request already reached WDA and the connection then dropped or the response was incomplete, it doesn't fall back to HID, because the action may have happened and redoing it would tap or type twice. The tool returns an error; the agent should take a screenshot first.+All parameters: [docs/tools.md](https://github.com/Derrors/iphone-control/blob/main/docs/tools.md) in the repository.diff --git a/website/en/guide/what-is-iphone-control.md b/website/en/guide/what-is-iphone-control.mdindex 212df51..9307a6f 100644--- a/website/en/guide/what-is-iphone-control.md+++ b/website/en/guide/what-is-iphone-control.md@@ -1,6 +1,6 @@# What is iphone-control?-iphone-control lets an AI agent such as Claude use a real iPhone that is plugged into a Linux machine or a Mac: look at the screen, tap buttons, type, open apps — like a person holding the phone.+iphone-control lets an AI agent such as Claude use a real iPhone or iPad that is plugged into a Linux machine or a Mac: look at the screen, tap buttons, type, open apps — like a person holding the phone.It works as a set of [MCP](https://modelcontextprotocol.io) (Model Context Protocol) tools, so any MCP client — Claude Code, Claude Desktop, Cursor and others — can use it directly.@@ -12,8 +12,8 @@ It works as a set of [MCP](https://modelcontextprotocol.io) (Model Context Proto## How it works-{.light-only}-{.dark-only}+{.light-only}+{.dark-only}- A **daemon** runs all the time and owns the phone: it pairs, mounts the Developer Disk Image, opens a tunnel, and runs [WebDriverAgent](https://github.com/appium/WebDriverAgent) (WDA, an agent on top of Apple's XCTest automation) on the phone to read the screen, tap and type.- The **MCP server** is started by the AI client on demand and simply forwards tool calls to the daemon.@@ -25,8 +25,8 @@ It works as a set of [MCP](https://modelcontextprotocol.io) (Model Context Proto| | ||---|---|| Host | Linux, x86_64 or arm64: Docker (Compose v2), or Rust 1.88+ to build from source<br>macOS, Apple Silicon: prebuilt binary, or Rust 1.88+ to build from source, see [macOS](../deploy/macos) |-| Phone | iOS 17 or later; the HID fallback needs iOS 27 or later |-| Verified on | iPhone 15 Pro Max, iOS 27.0.1 (Linux, macOS)<br>iPhone 12 mini, iOS 26.4.1 (Linux) |+| Phone | iPhone or iPad, iOS 17 or later; the HID fallback needs iOS 27 or later |+| Verified on | iPhone 15 Pro Max, iOS 27.0.1 (Linux, macOS)<br>iPhone 12 mini, iOS 26.4.1 (Linux)<br>iPad mini 5, iOS 26.6.1 (Linux, Docker) || Account | A free Apple ID; a dedicated one is recommended |Other models and iOS versions should work but are untested — [reports](https://github.com/Derrors/iphone-control/issues) are welcome.@@ -44,7 +44,7 @@ The CLI, `doctor` output and MCP tool results are currently in Simplified Chines**Usage**-- One phone per host. Don't run two copies of iphone-control, or other usbmuxd-based tools, against the same phone.+- A host can have several iPhones and iPads connected, but controls one at a time; see [Several devices](./multi-device). Don't run two copies of iphone-control, or other usbmuxd-based tools, against the same device.- Games, maps and video have no element tree; agents work from screenshots and coordinates there.- The HID fallback needs iOS 27 or later. On older iOS everything goes through WebDriverAgent, and actions fail while it restarts.- Free Apple ID profiles last 7 days. Re-signing is automatic, but an expired Apple ID session needs `login`.diff --git a/website/en/index.md b/website/en/index.mdindex e1931fa..add7e2e 100644--- a/website/en/index.md+++ b/website/en/index.md@@ -4,7 +4,7 @@ layout: homehero:name: iphone-controltext: Let AI agents use a real iPhone- tagline: Control an iPhone over USB from Linux or a Mac and hand it to Claude and other AI as MCP tools. No Xcode, no paid developer account.+ tagline: Control an iPhone or iPad over USB from Linux or a Mac and hand it to Claude and other AI as MCP tools. No Xcode, no paid developer account.image:src: /logo.svgalt: iphone-controldiff --git a/website/en/troubleshoot/faq.md b/website/en/troubleshoot/faq.mdindex 19dd5b3..7a018d2 100644--- a/website/en/troubleshoot/faq.md+++ b/website/en/troubleshoot/faq.md@@ -13,12 +13,12 @@ The program's messages are in Chinese; here is what they mean.| `status` shows | Meaning | What to do ||---|---|---|-| 手机未连接 | usbmuxd sees no phone | Check the cable and unlock the phone; with a usbmuxd on a Linux host, `sudo systemctl mask usbmuxd` |+| 手机未连接 | usbmuxd sees no phone | Check the cable and unlock the phone; with a usbmuxd on a Linux host, `sudo systemctl mask usbmuxd`. With several devices, a selected device that isn't connected also shows this: check the `选设备` line of `status`, or run `select auto`; see [Several devices](../guide/multi-device) || 未配对 | Not paired | Run `setup` and tap *Trust* on the phone || 开发者模式未打开 | Developer Mode is off | Run `setup` and follow the prompts |-| 手机锁屏,隧道建不起来 | Not unlocked since the last reboot | Unlock it once by hand |+| 手机锁屏,隧道建不起来 | Not unlocked since the last reboot | Unlock it once by hand; the state stays until then and the daemon keeps retrying || WDA 还没签名安装 | WDA not installed | Run `sign` or `setup` |-| 正在启动 WDA | Starting WDA (up to about 2 minutes) | Wait; taps, swipes and screenshots already work |+| 正在启动 WDA | Starting WDA (up to about 2 minutes) | Wait. On iOS 27 and later, taps, swipes and screenshots already work through the HID fallback, but a landscape touch needs an orientation from WDA in the last 30 seconds or it is refused, and an unknown screen size returns an error; see [Tools](../guide/tools#when-wda-is-down-the-hid-fallback). On older iOS, wait for WDA || WDA 卡在手机上的「Enable UI Automation」密码框 | The phone asks for the passcode for "XCTest" | Enter the passcode on the phone || WDA 启动失败,稍后重试:… | Other failure | Read the error after the colon and run `doctor` || 就绪 | Ready | — |@@ -37,7 +37,7 @@ The program's messages are in Chinese; here is what they mean.- **"Untrusted developer":** after the first install, trust your Apple ID under *Settings → General → VPN & Device Management* (the phone needs internet).- **Expired signature:** free signatures last 7 days and are renewed automatically. `status` shows the time left; `resign --force` re-signs now.- **Apple ID session expired:** you get a notification; run `login` again.-- **Developer Disk Image download fails:** it needs GitHub; set `HTTP_PROXY` / `HTTPS_PROXY`.+- **Developer Disk Image fails:** the first line of `status` says `WDA 启动失败,稍后重试:开发者镜像:…`, with details in `logs/daemon.log`; `doctor` has no separate check for it. Downloading needs GitHub; set `HTTP_PROXY` / `HTTPS_PROXY`, or point `ICTL_DDI_DIR` at a directory extracted from Xcode; see [Configuration](../guide/configuration#advanced).## Login@@ -48,6 +48,7 @@ The program's messages are in Chinese; here is what they mean.- **MCP disconnected:** restarting the container ends the MCP process; reconnect in the client (`/mcp` in Claude Code).- **"守护进程正忙…已放弃执行":** an action queued for over 30 seconds and was dropped rather than tapping a screen that changed. Take a screenshot and retry.+- **An action reports that the WDA connection dropped:** the request was already sent, so it may have happened. It isn't redone, to avoid tapping or typing twice. Take a screenshot first.- **Taps do nothing:** a system alert may be covering the screen; the result says so (「屏幕上有系统弹窗…」). Dismiss it first.- **Typed text is incomplete:** `iphone_type_text` reads the field back and fixes it; if it still reports a mismatch, the app rewrites the field while typing — type shorter pieces.diff --git a/website/guide/auto-unlock.md b/website/guide/auto-unlock.mdindex 9473b46..4a02c2c 100644--- a/website/guide/auto-unlock.md+++ b/website/guide/auto-unlock.md@@ -1,6 +1,6 @@# 自动解锁-默认关闭。开启后,手机锁屏时,MCP 操作前会先用你保存的锁屏密码解锁手机。+默认关闭。开启后,手机锁屏时,MCP 操作前会先用你保存的锁屏密码解锁手机。截图、读元素、`iphone_wait_for` 这些只读工具也一样。WDA 不可用时不会自动解锁。::: danger 先想清楚风险密码以**明文**存在数据目录里。能登录这台主机、能读数据目录备份、或能调用这个 MCP 的人,都能解锁你的手机。只在你完全掌控的主机上开启,最好用一部专门用来自动化的手机。@@ -15,7 +15,8 @@ docker exec -it iphone-control iphone-control passcode set密码存给守护进程正在控制的那台设备;要给别的设备设,加 `--device <UDID 或设备名>`。只支持 4 位以上的纯数字密码。关闭:```bash-docker exec -it iphone-control iphone-control passcode clear+docker exec -it iphone-control iphone-control passcode clear # 正在控制的那台;别的设备加 --device+docker exec -it iphone-control iphone-control passcode clear --all # 所有设备```## 多台设备@@ -28,18 +29,22 @@ docker exec -it iphone-control iphone-control passcode clear- 每按一位都核对密码栏的位数,对不上立即停止(没输完不算输错);只有第一位没生效时会重来,最多 3 轮。- 整串输完手机仍然锁着,就**立即停用**自动解锁并推送通知,不会第二次再试,因此不会累计输错触发抹掉数据。+- 从第 2 位起先写停用标记(数据目录的 `logs/UNLOCK-DISABLED`),确认解开或确认没输满才撤掉。所以输入中途出错、进程被杀,也会保持停用。+- 停用标记是**全局**的:一台失败,所有设备的自动解锁都停用。- 手机重启后第一次解锁(BFU)必须人工完成,自动解锁不处理。- 手机横放充电时会进入**待机显示**,那个界面调不出密码键盘,自动解锁会失败。开启自动解锁时,在「设置 → 待机显示」里把它关掉。## 停用后恢复-如果因为输错被停用(例如你改了锁屏密码),先更新密码,再恢复:+先人工解锁手机。如果是密码错了(例如你改了锁屏密码),先更新密码,再恢复:```bashdocker exec -it iphone-control iphone-control passcode setdocker exec -it iphone-control iphone-control unlock-reset```+如果是输入中途出错、进程被杀,密码本身可能没错,确认无误后只运行 `unlock-reset` 就行。`unlock-reset` 不会核对密码,`passcode set`、`passcode clear` 也不会解除停用。不要靠删除 `logs/` 来恢复,那会撤掉这层保护。+::: tip 不想用自动解锁可以在手机上把「设置 → 显示与亮度 → 自动锁定」设为「永不」,手机就不会自己锁屏。:::diff --git a/website/guide/cli.md b/website/guide/cli.mdnew file mode 100644index 0000000..e301d75--- /dev/null+++ b/website/guide/cli.md@@ -0,0 +1,71 @@+# 命令行++所有命令都是 `iphone-control <命令>`。Docker 部署时前面加 `docker exec -it iphone-control`;从源码运行和在 macOS 上直接运行。`--help` 看帮助,`--version` 看版本。++## 全局选项++写在命令前面,例如 `iphone-control --socket /path/ctl.sock mcp`。++| 选项 | 环境变量 | 含义 |+|---|---|---|+| `--data-dir <目录>` | `ICTL_DATA_DIR` | 数据目录,默认值见[配置](./configuration#目录和控制接口) |+| `--socket <路径>` | `ICTL_SOCKET` | 守护进程的控制接口,默认值同上 |++## 运行++| 命令 | 作用 |+|---|---|+| `daemon` | 常驻守护进程。容器的入口;从源码运行时由 systemd 或手动启动,macOS 上在终端里运行 |+| `mcp` | MCP stdio 服务,由 AI 客户端拉起 |+| `mcp-config [--container <容器名>]` | 打印把 MCP 注册到 Claude Code 的命令。在容器里或给了 `--container` 时打印 `docker exec` 的写法,否则直接调用本程序 |++## 安装与签名++| 命令 | 作用 |+|---|---|+| `setup` | 安装向导:配对、开发者模式、登录 Apple ID、签名安装 WDA。可重复运行,只作用于正在控制的那台 |+| `login [邮箱]` | 登录 Apple ID。密码和验证码只在这里输入;不给邮箱就交互输入 |+| `sign` | 立即签名并安装 WDA,同 `resign --force`。会把设备注册到 Apple ID |+| `resign [--force]` | 描述文件剩余不到 `RESIGN_MIN_DAYS` 天才重签;`--force` 立即重签。不带 `--force` 时不会替没装过 WDA 的设备注册 |++## 查看状态++| 命令 | 作用 |+|---|---|+| `status` | 状态、手机、选设备方式、描述文件还剩多久、自动解锁、通知、最近日志 |+| `doctor` | 逐层诊断,每项失败都给出修复办法 |++## 多台设备++见[多台设备](./multi-device)。++| 命令 | 作用 |+|---|---|+| `devices` | 列出 USB 上接着的设备,标出正在控制哪台、有没有设自动解锁密码 |+| `select <UDID\|设备名\|auto>` | 改为控制另一台,重启后还记得;`auto` 改回自动选 |++## 自动解锁++见[自动解锁](./auto-unlock)。`--device` 接 UDID 或设备名,设备要接着;不给就是正在控制的那台。++| 命令 | 作用 |+|---|---|+| `passcode set [--device <设备>]` | 保存这台设备的锁屏密码,开启自动解锁 |+| `passcode clear [--device <设备>]` | 删除这台设备的密码 |+| `passcode clear --all` | 删除所有设备的密码 |+| `unlock-reset` | 自动解锁被停用后恢复。它不核对密码,先自己确认密码没错 |++## 其他++| 命令 | 作用 |+|---|---|+| `notify-test [事件]` | 发测试通知:每类事件各一条,或只发一类(`resign`、`session`、`pin`、`pin-recovered`、`unlock`、`offline`、`online`) |+| `wda-bridge [--port <端口>]` | 把 WDA 桥接到 `127.0.0.1`,端口默认 8100,给别的工具用。WDA 没有认证,本机任何用户都能连上,用完就停 |++调试用的 `debug` 子命令默认不编译,见[贡献指南](https://github.com/Derrors/iphone-control/blob/main/CONTRIBUTING.md#testing-on-a-real-phone)。++## 使用说明++- **要守护进程在运行的:** `setup`、`status`、`doctor`、`sign`、`resign`、`devices`、`select`、`unlock-reset`,以及 MCP 工具调用。+- **要在终端里交互运行的:** `setup`、`login`、`passcode set`,Docker 部署要带 `-it`。+- **环境变量:** 命令行读的是当前 shell 的环境。从源码运行和在 macOS 上,`~/.config/iphone-control/env` 只有守护进程会加载;用 `login`、`setup`(如果配了 `ICTL_ANISETTE_URL`)、`notify-test` 前先运行 `set -a; . ~/.config/iphone-control/env; set +a`。diff --git a/website/guide/configuration.md b/website/guide/configuration.mdindex 48b7f54..2865459 100644--- a/website/guide/configuration.md+++ b/website/guide/configuration.md@@ -14,7 +14,7 @@| `HTTP_PROXY` / `HTTPS_PROXY` | 直连 | 访问苹果、anisette、开发者镜像、推送通知用的代理 || `IPHONE_UDID` | 自动选 | 固定控制哪台设备。不设时自动选:正在控制的那台一直用到它断开;运行中可以用 `select` 命令或 `iphone_select_device` 工具切换。设了就不能切换 || `RESIGN_MIN_DAYS` | `2` | 描述文件剩余不到几天时重签 |-| `RESIGN_CHECK_HOURS` | `6` | 每隔几小时检查一次 |+| `RESIGN_CHECK_HOURS` | `6` | 每隔几小时检查一次;手机重新连上或切换设备后 1 分钟内也查一次 || `OFFLINE_ALERT_MIN` | `10` | 手机离线超过几分钟推送提醒,`0` 不提醒 |通知相关的变量见[通知](./notifications)。@@ -24,11 +24,24 @@| 变量 | 含义 ||---|---|| `ICTL_ANISETTE_URL` | 自建 anisette 服务地址(默认用公共的第三方服务,见[安全与隐私](./security)) |-| `ICTL_DDI_URL` / `ICTL_DDI_DIR` | 开发者镜像的下载地址 / 本地目录(从 Xcode 提取) |-| `ICTL_MANAGE_USBMUXD` | 宿主机已经运行 usbmuxd 服务时设为 `0`,守护进程就不自己拉起 |-| `SCREEN_W` / `SCREEN_H` | WDA 从没连上过时,HID 后备路线换算坐标用的屏幕尺寸(点) |+| `ICTL_DDI_URL` | 开发者镜像的下载地址,默认社区维护的镜像仓库 |+| `ICTL_DDI_DIR` | 自己从 Xcode 提取的开发者镜像目录。设了就不下载,也不会删里面的文件;缺文件时报错说明缺哪个。不设时用数据目录下的 `ddi/` 缓存,连续 3 次挂载失败后清掉重新下载 |+| `ICTL_MANAGE_USBMUXD` | 守护进程是否自己拉起 usbmuxd。默认:以 root 运行(容器)时拉起,普通用户不拉起,用系统的。`0` 或 `false` 不拉起,例如以 root 运行、宿主机又已有 usbmuxd 服务时 |+| `ICTL_USBMUXD_BIN` | 守护进程自己拉起 usbmuxd 时用的可执行文件,默认 `usbmuxd` |+| `ICTL_WDA_UNSIGNED` | 未签名 WDA 的路径。默认:镜像里的 `/usr/share/iphone-control/WDA-unsigned.ipa`;没有镜像(从源码运行)时是数据目录的 `wda/WDA-unsigned.ipa`,第一次签名前下载。自己指定的路径不会下载 |+| `SCREEN_W` / `SCREEN_H` | HID 后备路线换算坐标用的屏幕尺寸(点):WDA 不可用、又没有这台设备的尺寸记录时才用,比如 WDA 从没连上过,或切到记录里没有尺寸的设备。不分设备,接多台时要小心 || `ICTL_LOG` | 日志级别,例如 `info,ictl_wda::http=debug` 记录每个 WDA 请求的耗时 |+## 目录和控制接口++一般不用改,Docker 部署不要改(容器里 `ICTL_DATA_DIR` 已经固定,数据卷挂在那里)。要改时不能写成空值,守护进程、命令行和 MCP 要用同样的值:除了容器,只有守护进程会读配置文件,见[从源码 / 二进制](../deploy/source#运行)。++| 变量 | 默认 | 含义 |+|---|---|---|+| `ICTL_DATA_DIR` | root:`/var/lib/iphone-control`<br>普通用户:`$XDG_DATA_HOME/iphone-control`,没设时 `~/.local/share/iphone-control` | 数据目录,同命令行的 `--data-dir` |+| `ICTL_SOCKET` | root:`/run/iphone-control/ctl.sock`<br>普通用户:`$XDG_RUNTIME_DIR/iphone-control/ctl.sock`,没有这个变量时(macOS)放在数据目录里 | 守护进程的控制接口,同命令行的 `--socket` |+| `XDG_DATA_HOME` / `XDG_RUNTIME_DIR` | 系统设置 | 不是本项目的变量,只影响普通用户时上面两项的默认位置 |+## 只给 Docker Compose 用的用仓库自带的 `compose.yaml` 时才有这几项;自己写 compose 文件时直接改对应的 `container_name`、`image`、`volumes`。diff --git a/website/guide/getting-started.md b/website/guide/getting-started.mdindex 0b68f20..50d80f1 100644--- a/website/guide/getting-started.md+++ b/website/guide/getting-started.md@@ -5,7 +5,7 @@## 准备- 一台 Linux 主机,装好 Docker(含 Compose v2)-- iPhone(iOS 17+)和能传数据的线+- iPhone 或 iPad(iOS 17+)和能传数据的线- 一个免费 Apple ID(建议专门注册一个)- 主机能访问苹果服务器和 GitHub;国内网络一般要配代理@@ -21,7 +21,7 @@ cp .env.example .env # 需要代理的话在这里填 HTTP_PROXY / HTTPS_docker compose up -d --build```-首次构建要编译 Rust,需要几分钟。发布了正式版本后也可以直接用预构建镜像,见 [Docker 部署](../deploy/docker)。+首次构建要编译 Rust,需要几分钟。也可以直接用预构建镜像,见 [Docker 部署](../deploy/docker)。## 2. 运行安装向导diff --git a/website/guide/multi-device.md b/website/guide/multi-device.mdnew file mode 100644index 0000000..778960b--- /dev/null+++ b/website/guide/multi-device.md@@ -0,0 +1,66 @@+# 多台设备++一台主机可以接多台 iPhone/iPad,但同一时间只控制一台:所有工具和命令都作用在它上面。只接一台时不用管这一页。++下面的命令在 Docker 部署时前面加 `docker exec -it iphone-control`。不要让两份 iphone-control 或其他基于 usbmuxd 的工具连同一台设备。++## 查看和切换++```bash+iphone-control devices # 列出接着的设备,标出正在控制哪台、有没有设自动解锁密码+iphone-control select <UDID 或设备名> # 改为控制这一台+iphone-control select auto # 改回自动选+```++agent 用 `iphone_list_devices` 和 `iphone_select_device`,效果一样。++- 只能选 USB 上接着的设备。先比 UDID,再比设备名;设备名包含这段文字且只有一台时也行,对上多台就报错,要用 UDID 指定。+- 切换后 WDA 要 10~60 秒才起来,先用 `status`(或 `iphone_status`)确认就绪。没装过 WDA 的设备要先[安装](#给新设备安装)。++## 控制哪一台++| 优先级 | 来源 | 行为 |+|---|---|---|+| 1 | 环境变量 `IPHONE_UDID` | 固定这一台,`select` 切不走 |+| 2 | `select` 或 `iphone_select_device` 选定的 | 写进 `state.json`,重启后还记得 |+| 3 | 自动选(没选过,或 `select auto`) | 正在控制的那台一直用到它断开,断开后换接着的另一台 |++**选定的设备没接时**,状态是「手机未连接」,不会换到另一台,免得操作和自动解锁落到别的设备上。离线超过 `OFFLINE_ALERT_MIN` 分钟还会推送离线通知。`status` 的「选设备」行能看到选的是哪台,`select auto` 恢复自动选。++**自动选时**,如果 `iphone_batch` 执行到一半控制的设备变了(比如拔线后换到另一台),批处理会停下报错。++## 给新设备安装++```bash+iphone-control select <新设备>+iphone-control setup+```++`setup` 只作用于正在控制的那台,所以要先 `select`。它会把设备注册到你的 Apple ID,占用账号的设备名额。自动重签不会替没装过 WDA 的设备注册,这时 `doctor` 会提示运行 `setup`。++## 重签++自动重签只管正在控制的那台。闲置设备的描述文件 7 天后过期,切回去后 1 分钟内会自动检查,快过期或已过期就重签;也可以运行 `resign --force`。++## 自动解锁++密码按设备分开存:++```bash+iphone-control passcode set --device <UDID 或设备名> # 设备要接着+```++停用标记是全局的:一台自动解锁失败,所有设备都停用,直到运行 `unlock-reset`。见[自动解锁](./auto-unlock)。++## 通知++通知文字不带设备名。收到通知时用 `status` 或 `devices` 看是哪台。++## iPad 的差异++- **Touch ID 机型:** 锁屏上滑后是「触控 ID」提示,要先点「使用密码」才有键盘,自动解锁时守护进程会自己点。+- **横屏:** 坐标按当前方向算,自动解锁和 HID 后备路线会换算回设备的原始方向。HID 后备路线在横屏时的限制见[工具一览](./tools#wda-不可用时-hid-后备)。+- **iOS 26 没有 HID 后备:** WDA 重启期间操作会失败,iPhone 上也一样。+- **屏幕尺寸不是 430×932:** iPad mini 5 竖放是 768×1024,以截图和 `iphone_status` 为准。++已验证:iPad mini 5,iOS 26.6.1(Linux,Docker)。diff --git a/website/guide/notifications.md b/website/guide/notifications.mdindex 476dece..6739509 100644--- a/website/guide/notifications.md+++ b/website/guide/notifications.md@@ -13,7 +13,14 @@| 自动解锁失败已停用 | 见[自动解锁](./auto-unlock) || 手机离线 / 恢复在线 | 检查数据线和主机 |-同一事件不会重复推送,恢复时推送一次。+不重复推送的规则:++- 重签失败、Apple ID 会话失效:20 小时内不重复,问题还在的话 20 小时后再推。+- 要输密码、手机离线:推一次,直到恢复。只有这两类有恢复推送(「WDA 已恢复」「已重新连上」)。+- 自动解锁停用:推一次,`unlock-reset` 后才可能再推。+- 这些记录只在内存里,守护进程重启后清空,还没解决的问题会再推一次。++通知文字不带设备名,接着多台时用 `status` 看是哪台,见[多台设备](./multi-device)。## Barkdiff --git a/website/guide/tools.md b/website/guide/tools.mdindex 597dbf3..dbd1a83 100644--- a/website/guide/tools.md+++ b/website/guide/tools.md@@ -1,6 +1,6 @@# 工具一览-MCP 服务提供 17 个工具。坐标单位是**点**,和整屏截图的像素一一对应(iPhone 15 Pro Max 是 430×932),agent 从截图上读到的位置可以直接点。+MCP 服务提供 17 个工具。坐标单位是**点**,和整屏截图的像素一一对应(iPhone 15 Pro Max 是 430×932),agent 从截图上读到的位置可以直接点。坐标随屏幕方向变化:转屏后同一个位置的坐标不同,要重新截图。不同设备屏幕尺寸不同,iPad mini 5 竖放是 768×1024。## 看屏幕@@ -9,7 +9,10 @@ MCP 服务提供 17 个工具。坐标单位是**点**,和整屏截图的像| `iphone_status` | WDA 是否就绪、是否锁屏、前台 App、屏幕尺寸 || `iphone_screenshot` | 截图;给出 `x`、`y`、`width`、`height` 时只返回这块区域的放大图,看清小字和小图标 || `iphone_list_elements` | 列出屏幕上带文字的元素:类型、文字、中心点、尺寸;`filter` 可按文字或类型筛选 |-| `iphone_wait_for` | 等某段文字出现(页面加载完、弹窗出现),出现就返回;输入框里的字不算 |+| `iphone_wait_for` | 等某段文字出现(页面加载完、弹窗出现),出现就返回;输入框里的字不算。`timeout` 默认 5 秒,最多 30 秒 |+| `iphone_list_apps` | 已安装的 App;只读,没有 `then` |++开启[自动解锁](./auto-unlock)时,手机锁着的话,`iphone_screenshot`、`iphone_list_elements`、`iphone_wait_for` 也会先解锁。这些工具标为「只读」,指的是不改界面内容。`iphone_status`、`iphone_list_apps` 不会解锁。## 操作@@ -17,14 +20,13 @@ MCP 服务提供 17 个工具。坐标单位是**点**,和整屏截图的像|---|---|| `iphone_tap` | 按坐标点击 || `iphone_tap_element` | 按文字点击;中心被悬浮栏、键盘挡住时改点露出来的部分,整个被挡住就不点 |-| `iphone_long_press` | 长按 |-| `iphone_swipe` | 滑动;列表停稳后才返回 |+| `iphone_long_press` | 长按;`seconds` 默认 1,最多 10 |+| `iphone_swipe` | 滑动;列表停稳后才返回。`seconds` 默认 0.3,最多 10 || `iphone_type_text` | 在当前输入框输入文字(支持中文),输完读回核对,丢字会补上;`submit` 时按回车 || `iphone_press_button` | `home`、`volume_up`、`volume_down`、`lock` || `iphone_launch_app` / `iphone_terminate_app` | 启动 / 结束 App,可以用名字(如「设置」)或 Bundle ID || `iphone_open_url` | 打开链接或 URL Scheme |-| `iphone_list_apps` | 已安装的 App |-| `iphone_batch` | 一次执行最多 20 步,出错就停 |+| `iphone_batch` | 一次执行最多 20 步,出错就停。MCP 客户端取消调用时,剩下的步骤不再执行;没选定设备时,执行中控制的设备变了也会停下报错 |## 接着多台设备@@ -35,9 +37,11 @@ MCP 服务提供 17 个工具。坐标单位是**点**,和整屏截图的像| `iphone_list_devices` | 列出 USB 上接着的 iPhone/iPad:名字、型号、iOS 版本、UDID,标出正在控制哪台、有没有设自动解锁密码 || `iphone_select_device` | 改为控制另一台(UDID 或设备名),重启后还记得;`auto` 改回自动选。新设备上的 WDA 起来要 10~60 秒。设了 `IPHONE_UDID` 时不能切换 |+详见[多台设备](./multi-device)。+## 操作后顺带看界面:`then`-每个操作工具都可以带 `then`,等界面稳定后顺带返回操作后的样子,省一次往返:+上面「操作」一节的工具都可以带 `then`,等界面稳定后顺带返回操作后的样子,省一次往返:| 参数 | 含义 ||---|---|@@ -48,4 +52,13 @@ MCP 服务提供 17 个工具。坐标单位是**点**,和整屏截图的像结果里会说明等了多久、页面是否可能还在加载、有没有弹窗挡着。不带 `then` 时,如果有系统弹窗挡着也会提醒。-完整参数见仓库里的 [docs/tools.md](https://github.com/Derrors/iphone-control/blob/main/docs/tools.md)。+## WDA 不可用时:HID 后备++连不上 WDA 时,截图、点击、滑动、按键改走 CoreDevice HID。有这些限制:++- 要 iOS 27 及以上。更早的 iOS 没有这条路线,WDA 重启期间操作会失败。+- **横屏**:每次触摸前都重新截图核对方向,还要 30 秒内从 WDA 拿到过方向并且和当前一致,否则拒绝触摸,不会猜(守护进程刚重启后就是这样)。截图和按键不受影响。WDA 掉线期间不要把设备翻到另一侧,等它恢复再翻。+- **屏幕尺寸**:WDA 不可用、又没有这台设备的尺寸记录时,点击和滑动报错。等 WDA 起来一次,或设 [`SCREEN_W`/`SCREEN_H`](./configuration#高级)。+- **不会重做**:请求已经发给 WDA、连接才断开或响应不完整时,不退到 HID,因为动作可能已经做了,重做会点两次、输两遍。工具会报错,agent 要先截图确认再决定。++完整参数见仓库里的 [docs/tools.md](https://github.com/Derrors/iphone-control/blob/main/docs/tools.md)(英文)。diff --git a/website/guide/what-is-iphone-control.md b/website/guide/what-is-iphone-control.mdindex 76c7fa9..195d816 100644--- a/website/guide/what-is-iphone-control.md+++ b/website/guide/what-is-iphone-control.md@@ -1,6 +1,6 @@# 什么是 iphone-control?-iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Linux 主机或 Mac 上的真实 iPhone:看屏幕、点按钮、输入文字、打开 App,就像人拿着手机一样。+iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Linux 主机或 Mac 上的真实 iPhone 或 iPad:看屏幕、点按钮、输入文字、打开 App,就像人拿着手机一样。它以 [MCP](https://modelcontextprotocol.io)(Model Context Protocol)工具的形式提供能力,支持 MCP 的客户端(Claude Code、Claude Desktop、Cursor 等)都能直接用。@@ -12,8 +12,8 @@ iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Lin## 怎么工作-{.light-only}-{.dark-only}+{.light-only}+{.dark-only}- **守护进程**常驻,独占手机:配对、挂载开发者镜像、建立隧道,在手机上运行 [WebDriverAgent](https://github.com/appium/WebDriverAgent)(WDA,苹果 XCTest 自动化框架上的代理),用它读界面、点击和输入。- **MCP 服务**由 AI 客户端按需拉起,只是把工具调用转给守护进程。@@ -25,8 +25,8 @@ iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Lin| | ||---|---|| 主机 | Linux,x86_64 或 arm64:Docker(Compose v2),或 Rust 1.88+ 从源码编译<br>macOS,Apple Silicon:预编译二进制,或 Rust 1.88+ 从源码编译,见 [macOS](../deploy/macos) |-| 手机 | iOS 17 及以上;HID 后备路线要 iOS 27 及以上 |-| 已在真机验证 | iPhone 15 Pro Max,iOS 27.0.1(Linux、macOS)<br>iPhone 12 mini,iOS 26.4.1(Linux) |+| 手机 | iPhone 或 iPad,iOS 17 及以上;HID 后备路线要 iOS 27 及以上 |+| 已在真机验证 | iPhone 15 Pro Max,iOS 27.0.1(Linux、macOS)<br>iPhone 12 mini,iOS 26.4.1(Linux)<br>iPad mini 5,iOS 26.6.1(Linux,Docker) || 账号 | 免费 Apple ID 即可,建议专门注册一个 |其他机型和 iOS 版本应该也能用,但还没测过,欢迎[反馈](https://github.com/Derrors/iphone-control/issues)。@@ -44,7 +44,7 @@ iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Lin**使用**-- 一台主机接一部手机。不要对同一部手机同时运行两份 iphone-control,也不要同时用其他基于 usbmuxd 的工具。+- 一台主机可以接多台 iPhone/iPad,但同一时间只控制一台,见[多台设备](./multi-device)。不要让两份 iphone-control 或其他基于 usbmuxd 的工具连同一台。- 游戏、地图、视频这类界面没有元素树,agent 只能看截图按坐标操作。- HID 后备路线要 iOS 27 及以上;更早的 iOS 全部经 WebDriverAgent 操作,WDA 重启期间操作会失败。- 免费 Apple ID 的描述文件 7 天有效。重签是自动的,但 Apple ID 会话失效后要运行 `login` 重新登录。diff --git a/website/index.md b/website/index.mdindex c810f5d..3c6f472 100644--- a/website/index.md+++ b/website/index.md@@ -4,7 +4,7 @@ layout: homehero:name: iphone-controltext: 让 AI agent 操作真实的 iPhone- tagline: 在 Linux 或 Mac 上通过 USB 控制 iPhone,以 MCP 工具交给 Claude 等 AI。不需要 Xcode,不需要付费开发者账号。+ tagline: 在 Linux 或 Mac 上通过 USB 控制 iPhone 或 iPad,以 MCP 工具交给 Claude 等 AI。不需要 Xcode,不需要付费开发者账号。image:src: /logo.svgalt: iphone-controldiff --git a/website/pnpm-lock.yaml b/website/pnpm-lock.yamlindex 6ac810b..0c9d649 100644--- a/website/pnpm-lock.yaml+++ b/website/pnpm-lock.yaml@@ -162,6 +162,9 @@ settings:autoInstallPeers: trueexcludeLinksFromLockfile: false+overrides:+ vite: 6.4.5+importers:.:@@ -291,141 +294,159 @@ packages:search-insights:optional: true- '@esbuild/[email protected]':- resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}+ engines: {node: '>=18'}cpu: [ppc64]os: [aix]- '@esbuild/[email protected]':- resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==}+ engines: {node: '>=18'}cpu: [arm64]os: [android]- '@esbuild/[email protected]':- resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==}+ engines: {node: '>=18'}cpu: [arm]os: [android]- '@esbuild/[email protected]':- resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==}+ engines: {node: '>=18'}cpu: [x64]os: [android]- '@esbuild/[email protected]':- resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==}+ engines: {node: '>=18'}cpu: [arm64]os: [darwin]- '@esbuild/[email protected]':- resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==}+ engines: {node: '>=18'}cpu: [x64]os: [darwin]- '@esbuild/[email protected]':- resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==}+ engines: {node: '>=18'}cpu: [arm64]os: [freebsd]- '@esbuild/[email protected]':- resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==}+ engines: {node: '>=18'}cpu: [x64]os: [freebsd]- '@esbuild/[email protected]':- resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==}+ engines: {node: '>=18'}cpu: [arm64]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==}+ engines: {node: '>=18'}cpu: [arm]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==}+ engines: {node: '>=18'}cpu: [ia32]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==}+ engines: {node: '>=18'}cpu: [loong64]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==}+ engines: {node: '>=18'}cpu: [mips64el]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==}+ engines: {node: '>=18'}cpu: [ppc64]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==}+ engines: {node: '>=18'}cpu: [riscv64]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==}+ engines: {node: '>=18'}cpu: [s390x]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==}+ engines: {node: '>=18'}cpu: [x64]os: [linux]- '@esbuild/[email protected]':- resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==}+ engines: {node: '>=18'}+ cpu: [arm64]+ os: [netbsd]++ '@esbuild/[email protected]':+ resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==}+ engines: {node: '>=18'}cpu: [x64]os: [netbsd]- '@esbuild/[email protected]':- resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==}+ engines: {node: '>=18'}+ cpu: [arm64]+ os: [openbsd]++ '@esbuild/[email protected]':+ resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==}+ engines: {node: '>=18'}cpu: [x64]os: [openbsd]- '@esbuild/[email protected]':- resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==}+ engines: {node: '>=18'}+ cpu: [arm64]+ os: [openharmony]++ '@esbuild/[email protected]':+ resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==}+ engines: {node: '>=18'}cpu: [x64]os: [sunos]- '@esbuild/[email protected]':- resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==}+ engines: {node: '>=18'}cpu: [arm64]os: [win32]- '@esbuild/[email protected]':- resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==}+ engines: {node: '>=18'}cpu: [ia32]os: [win32]- '@esbuild/[email protected]':- resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==}- engines: {node: '>=12'}+ '@esbuild/[email protected]':+ resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==}+ engines: {node: '>=18'}cpu: [x64]os: [win32]@@ -643,7 +664,7 @@ packages:resolution: {integrity: sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==}engines: {node: ^18.0.0 || >=20.0.0}peerDependencies:- vite: ^5.0.0 || ^6.0.0+ vite: 6.4.5vue: ^3.2.25'@vue/[email protected]':@@ -772,14 +793,23 @@ packages:resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}engines: {node: '>=0.12'}- resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}- engines: {node: '>=12'}+ resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==}+ engines: {node: '>=18'}hasBin: trueresolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}+ resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}+ engines: {node: '>=12.0.0'}+ peerDependencies:+ picomatch: ^3 || ^4+ peerDependenciesMeta:+ picomatch:+ optional: true+resolution: {integrity: sha512-/yNdlIkpWbM0ptxno3ONTuf+2g318kh2ez3KSeZN5dZ8YC6AAmgeWz+GasYYiBJPFaYcSAPeu4GfhUaChzIJXA==}@@ -844,6 +874,10 @@ packages:resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}+ resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}+ engines: {node: '>=12'}+resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==}engines: {node: ^10 || ^12 || >=14}@@ -903,6 +937,10 @@ packages:resolution: {integrity: sha512-dMCuwDUY6Noz3zVKLefBC4wq+aJV20yc7vWmM7uTNGwtQSFF5kX7OUIUsxuVajz/bdt5Xqdah3/0NLjth+cM5A==}+ resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}+ engines: {node: '>=12.0.0'}+resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}@@ -927,22 +965,27 @@ packages:resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}- resolution: {integrity: sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==}- engines: {node: ^18.0.0 || >=20.0.0}+ resolution: {integrity: sha512-4enwjFfi4IwtEh0w+jPzpLVOFQiPHmmzPxcHXQOyEur47o6u0jE573DmGpjA+7irXoMLYRZD5ZaFUEneS3abPg==}+ engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}hasBin: truepeerDependencies:- '@types/node': ^18.0.0 || >=20.0.0+ '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0+ jiti: '>=1.21.0'less: '*'lightningcss: ^1.21.0sass: '*'sass-embedded: '*'stylus: '*'sugarss: '*'- terser: ^5.4.0+ terser: ^5.16.0+ tsx: ^4.8.1+ yaml: ^2.4.2peerDependenciesMeta:'@types/node':optional: true+ jiti:+ optional: trueless:optional: truelightningcss:@@ -957,6 +1000,10 @@ packages:optional: trueterser:optional: true+ tsx:+ optional: true+ yaml:+ optional: trueresolution: {integrity: sha512-+2ym1/+0VVrbhNyRoFFesVvBvHAVMZMK0rw60E3X/5349M1GuVdKeazuksqopEdvkKwKGs21Q729jX81/bkBJg==}@@ -1133,73 +1180,82 @@ snapshots:transitivePeerDependencies:- '@algolia/client-search'- '@esbuild/[email protected]':+ '@esbuild/[email protected]':+ optional: true++ '@esbuild/[email protected]':+ optional: true++ '@esbuild/[email protected]':+ optional: true++ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true- '@esbuild/[email protected]':+ '@esbuild/[email protected]':optional: true'@iconify-json/[email protected]':@@ -1356,9 +1412,9 @@ snapshots:'@ungap/[email protected]': {}dependencies:- vite: 5.4.21+ vite: 6.4.5vue: 3.5.44'@vue/[email protected]':@@ -1501,34 +1557,41 @@ snapshots:optionalDependencies:- '@esbuild/aix-ppc64': 0.21.5- '@esbuild/android-arm': 0.21.5- '@esbuild/android-arm64': 0.21.5- '@esbuild/android-x64': 0.21.5- '@esbuild/darwin-arm64': 0.21.5- '@esbuild/darwin-x64': 0.21.5- '@esbuild/freebsd-arm64': 0.21.5- '@esbuild/freebsd-x64': 0.21.5- '@esbuild/linux-arm': 0.21.5- '@esbuild/linux-arm64': 0.21.5- '@esbuild/linux-ia32': 0.21.5- '@esbuild/linux-loong64': 0.21.5- '@esbuild/linux-mips64el': 0.21.5- '@esbuild/linux-ppc64': 0.21.5- '@esbuild/linux-riscv64': 0.21.5- '@esbuild/linux-s390x': 0.21.5- '@esbuild/linux-x64': 0.21.5- '@esbuild/netbsd-x64': 0.21.5- '@esbuild/openbsd-x64': 0.21.5- '@esbuild/sunos-x64': 0.21.5- '@esbuild/win32-arm64': 0.21.5- '@esbuild/win32-ia32': 0.21.5- '@esbuild/win32-x64': 0.21.5+ '@esbuild/aix-ppc64': 0.25.12+ '@esbuild/android-arm': 0.25.12+ '@esbuild/android-arm64': 0.25.12+ '@esbuild/android-x64': 0.25.12+ '@esbuild/darwin-arm64': 0.25.12+ '@esbuild/darwin-x64': 0.25.12+ '@esbuild/freebsd-arm64': 0.25.12+ '@esbuild/freebsd-x64': 0.25.12+ '@esbuild/linux-arm': 0.25.12+ '@esbuild/linux-arm64': 0.25.12+ '@esbuild/linux-ia32': 0.25.12+ '@esbuild/linux-loong64': 0.25.12+ '@esbuild/linux-mips64el': 0.25.12+ '@esbuild/linux-ppc64': 0.25.12+ '@esbuild/linux-riscv64': 0.25.12+ '@esbuild/linux-s390x': 0.25.12+ '@esbuild/linux-x64': 0.25.12+ '@esbuild/netbsd-arm64': 0.25.12+ '@esbuild/netbsd-x64': 0.25.12+ '@esbuild/openbsd-arm64': 0.25.12+ '@esbuild/openbsd-x64': 0.25.12+ '@esbuild/openharmony-arm64': 0.25.12+ '@esbuild/sunos-x64': 0.25.12+ '@esbuild/win32-arm64': 0.25.12+ '@esbuild/win32-ia32': 0.25.12+ '@esbuild/win32-x64': 0.25.12+ optionalDependencies:+ picomatch: 4.0.7+dependencies:tabbable: 6.5.1@@ -1609,6 +1672,8 @@ snapshots:+ [email protected]: {}+dependencies:nanoid: 3.3.20@@ -1694,6 +1759,11 @@ snapshots:+ dependencies:+ fdir: 6.5.0([email protected])+ picomatch: 4.0.7+@@ -1729,11 +1799,14 @@ snapshots:'@types/unist': 3.0.3vfile-message: 4.0.3dependencies:- esbuild: 0.21.5+ esbuild: 0.25.12+ fdir: 6.5.0([email protected])+ picomatch: 4.0.7postcss: 8.5.32rollup: 4.67.2+ tinyglobby: 0.2.17optionalDependencies:fsevents: 2.3.3@@ -1746,7 +1819,7 @@ snapshots:'@shikijs/transformers': 2.5.0'@shikijs/types': 2.5.0'@types/markdown-it': 14.2.0- '@vitejs/plugin-vue': 5.2.4([email protected])([email protected])+ '@vitejs/plugin-vue': 5.2.4([email protected])([email protected])'@vue/devtools-api': 7.7.10'@vue/shared': 3.5.44'@vueuse/core': 12.8.2@@ -1755,7 +1828,7 @@ snapshots:mark.js: 8.11.1minisearch: 7.2.0shiki: 2.5.0- vite: 5.4.21+ vite: 6.4.5vue: 3.5.44optionalDependencies:postcss: 8.5.32@@ -1769,6 +1842,7 @@ snapshots:- drauu- fuse.js- idb-keyval+ - jiti- jwt-decode- less- lightningcss@@ -1784,8 +1858,10 @@ snapshots:- stylus- sugarss- terser+ - tsx- typescript- universal-cookie+ - yamldependencies:diff --git a/website/pnpm-workspace.yaml b/website/pnpm-workspace.yamlindex 5ed0b5a..4d58033 100644--- a/website/pnpm-workspace.yaml+++ b/website/pnpm-workspace.yaml@@ -1,2 +1,6 @@allowBuilds:esbuild: true+# VitePress 1.6.4(最新正式版)依赖 vite 5,vite 5 的开发服务器漏洞没有修复版:强制用修过的 vite 6。+# 只影响构建文档站用的开发依赖;VitePress 出了依赖新版 vite 的正式版后去掉+overrides:+ vite: 6.4.5diff --git a/website/public/architecture-dark.svg b/website/public/architecture-dark.svgindex 200d3a4..d04eddb 100644--- a/website/public/architecture-dark.svg+++ b/website/public/architecture-dark.svg@@ -1,4 +1,4 @@-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" width="1200" height="600" role="img" aria-label="iphone-control architecture: an MCP client talks to iphone-control mcp over stdio, which talks to the daemon over a Unix socket; the daemon drives the iPhone over USB through WebDriverAgent, with CoreDevice HID as fallback">+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" width="1200" height="600" role="img" aria-label="iphone-control architecture: an MCP client talks to iphone-control mcp over stdio, which talks to the daemon over a Unix socket; the daemon drives the iPhone or iPad over USB through WebDriverAgent, with CoreDevice HID as fallback"><title>iphone-control architecture</title><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse">@@ -21,7 +21,7 @@<!-- Linux host --><rect x="16" y="16" width="900" height="568" rx="24" fill="none" stroke="#3d444d" stroke-width="2" stroke-dasharray="8 6"/>- <text x="44" y="54" class="frame"><tspan style="font-weight:700;fill:#e6edf3">Linux host</tspan> · Docker or systemd user service</text>+ <text x="44" y="54" class="frame"><tspan style="font-weight:700;fill:#e6edf3">Linux or macOS host</tspan> · Docker, systemd user service or a terminal</text><!-- AI client --><rect x="48" y="88" width="260" height="128" rx="16" fill="#151b23" stroke="#3d444d" stroke-width="1.5"/>@@ -72,7 +72,7 @@<rect x="990" y="72" width="180" height="350" rx="36" fill="#e6edf3"/><rect x="1002" y="84" width="156" height="326" rx="26" fill="url(#screen)"/><rect x="1050" y="96" width="60" height="16" rx="8" fill="#0b1220"/>- <text x="1080" y="196" text-anchor="middle" style="fill:#ffffff;font-size:22px;font-weight:700">iPhone</text>+ <text x="1080" y="196" text-anchor="middle" style="fill:#ffffff;font-size:20px;font-weight:700">iPhone / iPad</text><text x="1080" y="222" text-anchor="middle" style="fill:#ffffff;font-size:15px;opacity:.8">iOS 17+</text><rect x="1018" y="262" width="124" height="64" rx="12" fill="#ffffff" fill-opacity="0.14"/><text x="1080" y="290" text-anchor="middle" style="fill:#ffffff;font-size:15px;font-weight:600">WebDriver</text>diff --git a/website/public/architecture-light.svg b/website/public/architecture-light.svgindex c60ad94..f051f23 100644--- a/website/public/architecture-light.svg+++ b/website/public/architecture-light.svg@@ -1,4 +1,4 @@-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" width="1200" height="600" role="img" aria-label="iphone-control architecture: an MCP client talks to iphone-control mcp over stdio, which talks to the daemon over a Unix socket; the daemon drives the iPhone over USB through WebDriverAgent, with CoreDevice HID as fallback">+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" width="1200" height="600" role="img" aria-label="iphone-control architecture: an MCP client talks to iphone-control mcp over stdio, which talks to the daemon over a Unix socket; the daemon drives the iPhone or iPad over USB through WebDriverAgent, with CoreDevice HID as fallback"><title>iphone-control architecture</title><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse">@@ -21,7 +21,7 @@<!-- Linux host --><rect x="16" y="16" width="900" height="568" rx="24" fill="none" stroke="#d0d7de" stroke-width="2" stroke-dasharray="8 6"/>- <text x="44" y="54" class="frame"><tspan style="font-weight:700;fill:#1f2328">Linux host</tspan> · Docker or systemd user service</text>+ <text x="44" y="54" class="frame"><tspan style="font-weight:700;fill:#1f2328">Linux or macOS host</tspan> · Docker, systemd user service or a terminal</text><!-- AI client --><rect x="48" y="88" width="260" height="128" rx="16" fill="#f6f8fa" stroke="#d0d7de" stroke-width="1.5"/>@@ -72,7 +72,7 @@<rect x="990" y="72" width="180" height="350" rx="36" fill="#1f2328"/><rect x="1002" y="84" width="156" height="326" rx="26" fill="url(#screen)"/><rect x="1050" y="96" width="60" height="16" rx="8" fill="#0b1220"/>- <text x="1080" y="196" text-anchor="middle" style="fill:#ffffff;font-size:22px;font-weight:700">iPhone</text>+ <text x="1080" y="196" text-anchor="middle" style="fill:#ffffff;font-size:20px;font-weight:700">iPhone / iPad</text><text x="1080" y="222" text-anchor="middle" style="fill:#ffffff;font-size:15px;opacity:.8">iOS 17+</text><rect x="1018" y="262" width="124" height="64" rx="12" fill="#ffffff" fill-opacity="0.14"/><text x="1080" y="290" text-anchor="middle" style="fill:#ffffff;font-size:15px;font-weight:600">WebDriver</text>diff --git a/website/troubleshoot/faq.md b/website/troubleshoot/faq.mdindex 0e341f6..1035593 100644--- a/website/troubleshoot/faq.md+++ b/website/troubleshoot/faq.md@@ -11,12 +11,12 @@ iphone-control doctor # 逐层检查,每项失败都给出修复办法| `status` 显示 | 含义 | 怎么办 ||---|---|---|-| 手机未连接 | usbmuxd 看不到手机 | 检查数据线、解锁手机;Linux 宿主机装了 usbmuxd 时 `sudo systemctl mask usbmuxd` |+| 手机未连接 | usbmuxd 看不到手机 | 检查数据线、解锁手机;Linux 宿主机装了 usbmuxd 时 `sudo systemctl mask usbmuxd`。接着多台时,选定的那台没接也显示这个:看 `status` 的「选设备」行,或运行 `select auto`,见[多台设备](../guide/multi-device) || 未配对 | 没有配对记录 | 运行 `setup`,手机上点「信任」 || 开发者模式未打开 | — | 运行 `setup`,按提示在手机上打开 |-| 手机锁屏,隧道建不起来 | 重启后还没解锁过 | 手动解锁一次 |+| 手机锁屏,隧道建不起来 | 重启后还没解锁过 | 手动解锁一次;解锁前状态一直是这个,守护进程会定期重试 || WDA 还没签名安装 | — | 运行 `sign` 或 `setup` |-| 正在启动 WDA | 最长约 2 分钟 | 等一下;期间点击、滑动、截图仍可用 |+| 正在启动 WDA | 最长约 2 分钟 | 等一下。iOS 27 起期间点击、滑动、截图走 HID 后备,仍可用,但横屏时要 30 秒内从 WDA 拿到过方向,否则拒绝触摸;屏幕尺寸未知时报错,见[工具一览](../guide/tools#wda-不可用时-hid-后备)。更早的 iOS 要等 WDA 起来 || WDA 卡在手机上的「Enable UI Automation」密码框 | 手机在等「为 XCTest 输入 iPhone 密码」 | 在手机上输入锁屏密码 || WDA 启动失败,稍后重试:… | 其他原因 | 看冒号后的错误,运行 `doctor` || 就绪 | 一切正常 | — |@@ -35,7 +35,7 @@ iphone-control doctor # 逐层检查,每项失败都给出修复办法- **「不受信任的开发者」:** 首次安装后在 设置 → 通用 → VPN 与设备管理 里信任你的 Apple ID(手机要联网)。- **签名过期:** 免费签名 7 天有效,会自动重签。`status` 能看到还剩多久,`resign --force` 立即重签。- **Apple ID 会话失效:** 会收到通知,重新运行 `login`。-- **开发者镜像下载失败:** 需要能访问 GitHub,配好 `HTTP_PROXY` / `HTTPS_PROXY`。+- **开发者镜像失败:** `status` 第一行显示「WDA 启动失败,稍后重试:开发者镜像:…」,详情在 `logs/daemon.log`;`doctor` 没有单独的镜像检查。下载需要能访问 GitHub,配好 `HTTP_PROXY` / `HTTPS_PROXY`,或用 `ICTL_DDI_DIR` 指向从 Xcode 提取的目录,见[配置](../guide/configuration#高级)。## 登录@@ -46,6 +46,7 @@ iphone-control doctor # 逐层检查,每项失败都给出修复办法- **MCP 连接断开:** 容器重启会断开 MCP 进程,在客户端里重新连接(Claude Code 运行 `/mcp`)。- **「守护进程正忙…已放弃执行」:** 一个操作排队超过 30 秒,为免点到已经变了的屏幕而放弃。截图看看再重试。+- **操作报错说 WDA 连接中途断开:** 请求已经发出,动作可能已经做了,为免点两次、输两遍不会重做。先截图确认。- **点了没反应:** 可能有系统弹窗挡着,工具结果里会提示「屏幕上有系统弹窗…」,先点掉它。- **输入的字不全:** `iphone_type_text` 会读回核对并补上;仍提示对不上时,说明 App 在输入过程中改写了输入框,分几段输入。