Skip to content

Add iOS Simulator control and live panel (macOS) - #136

Merged
2 commits merged into
masterfrom
claude/ios-simulator
Oct 16, 2026
Merged

2 commits merged into
masterfrom
claude/ios-simulator

Conversation

@shaohaozhi286

Copy link
Copy Markdown
Collaborator

为什么

iOS 同事需要让 Agent 在 Xcode iOS 模拟器里运行、测试、目视检查 App,并在 ACECode 里实时观看和操作模拟器。参照 Claude Desktop 的同类功能逆向分析后自研复刻;与它不同的是 不依赖 xcode-select:Xcode 常被绿色安装在 /Applications 之外,必须自动发现且可配置。

改了什么

  • acecode-ios-sim helper(Objective-C++,仅 macOS):运行期加载所选 Xcode 的私有 CoreSimulator / SimulatorKit(无链接期符号)。设备描述、按界面方向转正的截图(1 像素 = 1 point)、限帧去重的 JPEG 实时流、HID 输入(Xcode ≤ 26 用 Indigo,CoreSimulator ≥ 1155.4 / Xcode 27 用 dtuhidd)、横竖屏换算、无障碍树。stdio 上的定长帧 JSON+二进制协议,随父进程退出。
  • Xcode 发现:配置路径 > DEVELOPER_DIR > xcode-select(须是完整 Xcode)> /Applications、~/Applications、Spotlight 中最新的;simctl / xcodebuild 直接从所选 Xcode 的 Developer 目录执行。
  • 模型工具 ios_simulator(list/boot/shutdown/attach/detach/screenshot/tap/swipe/touch_path/touch2_path/text/key/button/open_url/launch/terminate/list_apps/inspect/logs/hardware_keyboard)与 ios_simulator_build。控制工具像 Agent Browser 一样免逐次确认,但每台模拟器首次使用前询问用户一次(记在 state.json,可在设置撤销,超时/取消一律算拒绝);构建工具会执行工程脚本,保留普通权限确认。plan 模式只允许观察类动作。
  • Web:REST 路由 + WS /ws/ios-simulator/<udid> 实时流;预览区「iOS 模拟器」页签(鼠标/滚轮/键盘/粘贴交互,attach 时自动打开,标题栏有手动入口);设置 > 工具 > iOS 模拟器(启用、Xcode 选择与自定义路径、设备授权、启动/关闭、流画质)。
  • 打包只进 macOS:CMake if(APPLE) 目标;ACECode.app、便携包、PKG、更新包、npm darwin 包与 CI 校验都要求有它;Windows / Linux 不构建不打包。相关打包脚本测试与 verify-package 已同步。
  • 文档:docs/ios-simulator.md、docs/daemon-api.md 第 20 节、CLAUDE.md;openspec add-ios-simulator。协议形状参照 Meta idb(MIT,许可证随 helper 源码附带)。

验证

本机 Intel Mac,Xcode 26.6 绿色安装于 ~/Downloads(xcode-select 指向 CLT),iOS 26.5 两台已启动模拟器:

  • helper 直驱:describe、竖/横屏截图、Home、滑动翻页、点击启动 App、键盘、无障碍(设置 / SpringBoard / 横屏游戏)、推流。
  • IosSimulator* / XcodeLocator* / SimctlParse* 单测 30 项通过;真机 IosSimulatorE2E.*(授权、截图附件、Home、inspect、滑动、组合键、越界拒绝、推流)通过。
  • 独立端口 daemon:status(Spotlight 发现 Xcode)、devices、inspect、PNG 截图、配置 PUT、WebSocket 推流与面板按键。
  • 浏览器内实测设置页与实时面板:拖动翻页、工具栏 Home 生效。pnpm test、pnpm build 通过。
  • CI lint 全套(layers / size / ownership --final / includes / doc paths / map)带新文件无发现;macOS 打包脚本测试通过。
  • 全量单测在本机 macOS 上 6281 通过;11 个失败 + RemoteWebTcpProxy 崩溃均在远程 Web 代理、WebSocket 客户端、跨进程锁、沙箱路径、TUI 渲染、通道日志与 macOS 浏览器工具注册等与本改动无关的用例。

未验证:Xcode 27 上的 dtuhidd 输入通道;签名公证包(交给 CI);真实模型 attach 自动开面板(前端单测覆盖)。后续项:helper 的 Seatbelt 沙盒、Desktop 原生零拷贝模拟器视图(Intel 上动画期间帧缓冲回读会被 GPU 同步拖慢,Apple 的 simctl io screenshot 也一样)。

🤖 Generated with Claude Code

haozhi shao and others added 2 commits October 16, 2026 09:47
Let the agent run, test and visually check iOS apps in the Xcode iOS
Simulator, and let users watch and drive the simulator inside ACECode.

- acecode-ios-sim: an Objective-C++ helper that loads the selected Xcode's
  private CoreSimulator / SimulatorKit at runtime (no link-time symbols).
  It describes devices, captures the framebuffer turned to the interface
  orientation, streams rate-limited JPEG frames, injects HID input (Indigo
  for Xcode <= 26, the dtuhidd digitizer for CoreSimulator >= 1155.4) and
  reads the accessibility tree. Framed JSON+binary protocol over stdio.
- Xcode discovery without xcode-select: configured path, DEVELOPER_DIR,
  xcode-select, /Applications, ~/Applications and Spotlight, so copies of
  Xcode outside /Applications work; simctl and xcodebuild run from the
  chosen Xcode's own Developer directory.
- Tools ios_simulator (attach, screenshot, tap, swipe, touch paths, text,
  key, button, open_url, launch, inspect, logs, boot, ...) and
  ios_simulator_build. The control tool is auto-approved but asks once per
  simulator before first use; the build tool keeps the permission prompt.
- REST routes, a WebSocket stream, a live simulator preview tab with
  mouse/keyboard/paste input that opens on attach, and Settings > Tools >
  iOS 模拟器 for Xcode selection, device consent and stream quality.
- The helper is built and packaged only for macOS (app bundle, portable
  zip, pkg, update zip, npm darwin packages); package checks updated.

Protocol shapes follow Meta's idb (MIT, license included with the helper).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	web/scripts/i18n-en-overrides.mjs
@shaohaozhi286 shaohaozhi286 closed this pull request by merging all changes into master in 0da39f3 Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant