conorluddy/ios-simulator-skill
GitHub: conorluddy/ios-simulator-skill
为 Claude Code 提供一套高度 Token 优化的 iOS 模拟器构建、导航与测试自动化脚本集,让 AI 代理能高效完成 iOS 应用的开发与交互任务。
Stars: 937 | Forks: 64
[](https://deepwiki.com/conorluddy/ios-simulator-skill)
# Claude Code 的 iOS Simulator Skill
专为构建、测试和自动化 iOS 应用而设计的生产就绪技能。包含 22 个脚本,为人类开发者和 AI 代理进行了深度优化。
## Xcode 构建 + 模拟器自动化
本技能涵盖了 iOS 开发的两个方面:
- 通过 `xcodebuild` 进行 **Xcode 构建** — 编译、测试,并通过渐进式错误披露解析结果
- 通过 `xcrun simctl` 和 `idb` 进行 **模拟器交互** — 语义化 UI 导航、无障碍测试、设备生命周期管理
如果您只需要 Xcode 构建工具而不需要模拟器脚本,请查看插件版本:[xclaude-plugin](https://github.com/conorluddy/xclaude-plugin)
## 安装说明
### 通过插件市场安装(推荐)
在 Claude Code 中:
```
/plugin marketplace add conorluddy/ios-simulator-skill
/plugin install ios-simulator-skill@conorluddy
```
### 通过 Git Clone 安装
```
# 个人安装
git clone https://github.com/conorluddy/ios-simulator-skill.git ~/.claude/skills/ios-simulator-skill
# 项目安装
git clone https://github.com/conorluddy/ios-simulator-skill.git .claude/skills/ios-simulator-skill
```
重启 Claude Code。该技能将自动加载。
### 前置条件
- macOS 12+
- Xcode Command Line Tools (`xcode-select --install`)
- Python 3
- IDB(可选,用于交互功能:`brew tap facebook/fb && brew install idb-companion`)
- Pillow(可选,用于视觉差异对比:`pip3 install pillow`)
## 功能特性
### 带有渐进式披露的 Xcode 构建
`build_and_test.py` 脚本封装了 `xcodebuild`,可提供 Token 高效的输出。构建过程会返回带有 xcresult ID 的单行摘要:
```
Build: SUCCESS (0 errors, 3 warnings) [xcresult-20251018-143052]
```
然后可以根据需要深入了解细节:
```
python scripts/build_and_test.py --get-errors xcresult-20251018-143052
python scripts/build_and_test.py --get-warnings xcresult-20251018-143052
python scripts/build_and_test.py --get-log xcresult-20251018-143052
```
这使得代理的对话保持专注——除非您主动要求,否则不会显示大量构建输出。
### 通过 Accessibility 进行模拟器导航
所有导航均使用 iOS Accessibility API 按语义查找元素,而不是通过脆弱的像素坐标点击:
```
# 脆弱 — UI 变化会导致失效
idb ui tap 320 400
# 稳健 — 基于含义查找
python scripts/navigator.py --find-text "Login" --tap
```
Accessibility 树可提供结构化数据(元素类型、标签、边框、点击目标),默认输出仅约 10 个 Token,而截图通常需要 1,600-6,300 个 Token。请参阅 [AI-Accessible Apps](https://www.conor.fyi/writing/ai-access),了解为什么无障碍优先导航对 AI 代理至关重要。
### 截图 Token 优化
当需要截图时(如视觉验证、错误报告、差异对比),该技能会自动调整大小并进行压缩,以最大程度降低 Token 成本。所有 22 个脚本的默认输出均为 3-5 行——相比原始工具输出减少了 96%。
| 任务 | 原始工具 | 本技能 | 节省比例 |
|------|-----------|-----------|---------|
| 屏幕分析 | 200+ 行 | 5 行 | 97.5% |
| 查找并点击按钮 | 100+ 行 | 1 行 | 99% |
| 登录流程 | 400+ 行 | 15 行 | 96% |
### 全部 22 个脚本
每个脚本都支持 `--help` 和 `--json`。有关完整参考,请参阅 **SKILL.md**。
#### 构建与开发
| 脚本 | 功能描述 | 关键标志 |
|--------|-------------|-----------|
| `build_and_test.py` | 构建 Xcode 项目、运行测试、解析 xcresult 包 | `--project`, `--scheme`, `--test`, `--get-errors`, `--get-warnings` |
| `log_monitor.py` | 具有严重性过滤的实时日志监控 | `--app`, `--severity`, `--follow`, `--duration` |
#### 导航与交互
| 脚本 | 功能描述 | 关键标志 |
|--------|-------------|-----------|
| `screen_mapper.py` | 分析当前屏幕,列出可交互元素 | `--verbose`, `--hints` |
| `navigator.py` | 语义化查找并交互元素 | `--find-text`, `--find-type`, `--find-id`, `--tap`, `--enter-text` |
| `gesture.py` | 滑动、滚动、捏合、长按、下拉刷新 | `--swipe`, `--scroll`, `--pinch`, `--long-press`, `--refresh` |
| `keyboard.py` | 文本输入和硬件按键控制 | `--type`, `--key`, `--button`, `--clear`, `--dismiss` |
| `app_launcher.py` | 启动、终止、安装应用及深度链接 | `--launch`, `--terminate`, `--install`, `--open-url`, `--list` |
#### 测试与分析
| 脚本 | 功能描述 | 关键标志 |
|--------|-------------|-----------|
| `accessibility_audit.py` | 在当前屏幕进行 WCAG 合规性检查 | `--verbose`, `--output` |
| `visual_diff.py` | 对比两张截图以查找视觉变化 | `--threshold`, `--output`, `--details` |
| `test_recorder.py` | 带有截图的自动化测试记录 | `--test-name`, `--output` |
| `app_state_capture.py` | 调试快照(截图、层级、日志) | `--app-bundle-id`, `--output`, `--log-lines` |
| `sim_health_check.sh` | 验证环境(Xcode、simctl、IDB、Python) | — |
| `model_inspector.py` | 从项目文件中检查 Core Data / SwiftData 模型 | `--project-path`, `--raw`, `--show-versions` |
#### 权限与环境
| 脚本 | 功能描述 | 关键标志 |
|--------|-------------|-----------|
| `clipboard.py` | 复制文本到模拟器剪贴板以进行粘贴测试 | `--copy`, `--test-name` |
| `status_bar.py` | 覆盖状态栏(时间、电池、网络) | `--preset`, `--time`, `--battery-level`, `--clear` |
| `push_notification.py` | 发送模拟推送通知 | `--bundle-id`, `--title`, `--body`, `--payload` |
| `privacy_manager.py` | 授予、撤销、重置应用权限(13 项服务) | `--bundle-id`, `--grant`, `--revoke`, `--reset` |
#### 设备生命周期
| 脚本 | 功能描述 | 关键标志 |
|--------|-------------|-----------|
| `simctl_boot.py` | 启动模拟器并验证就绪状态 | `--name`, `--wait-ready`, `--timeout`, `--all`, `--type` |
| `simctl_shutdown.py` | 优雅地关闭模拟器 | `--name`, `--verify`, `--all`, `--type` |
| `simctl_create.py` | 根据设备类型和系统版本创建模拟器 | `--device`, `--runtime`, `--list-devices` |
| `simctl_delete.py` | 带有安全确认的模拟器删除操作 | `--name`, `--yes`, `--all`, `--old` |
| `simctl_erase.py` | 恢复出厂设置但不删除设备 | `--name`, `--verify`, `--all`, `--booted` |
## 评估
使用 [Claude Code evals](https://docs.claude.com/en/docs/claude-code/evals) 进行的测试:
| 条件 | 通过率 |
|-----------|-----------|
| 使用本技能 | **100%** (3/3) |
| 未使用本技能 | **46%** (~1.4/3) |
```
claude evals run evals/evals.json --skill ios-simulator-skill
```
## 许可证
MIT
标签:AI编程助手, App构建, Claude Code, DLL 劫持, idb, iOS开发, iOS模拟器, LLM工具, Python, UI交互, Xcode, xcodebuild, xcrun simctl, 大语言模型, 威胁情报, 开发者工具, 开源框架, 持续集成, 插件, 无后门, 移动应用开发, 脚本工具, 辅助功能测试, 逆向工具