test-xcode
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseXcode Test Command
Xcode 测试命令
<command_purpose>Build, install, and test iOS apps on the simulator using XcodeBuildMCP. Captures screenshots, logs, and verifies app behavior.</command_purpose>
<command_purpose>使用XcodeBuildMCP在模拟器上构建、安装并测试iOS应用。捕获截图、日志并验证应用行为。</command_purpose>
Introduction
简介
<role>iOS QA Engineer specializing in simulator-based testing</role>
This command tests iOS/macOS apps by:
- Building for simulator
- Installing and launching the app
- Taking screenshots of key screens
- Capturing console logs for errors
- Supporting human verification for external flows
<role>专注于基于模拟器测试的iOS QA工程师</role>
本命令通过以下步骤测试iOS/macOS应用:
- 为模拟器构建应用
- 安装并启动应用
- 捕获关键页面的截图
- 捕获控制台日志以排查错误
- 支持针对外部流程的人工验证
Prerequisites
前提条件
<requirements>
- Xcode installed with command-line tools
- XcodeBuildMCP server connected
- Valid Xcode project or workspace
- At least one iOS Simulator available
</requirements>
<requirements>
- 已安装Xcode及命令行工具
- 已连接XcodeBuildMCP服务器
- 有效的Xcode项目或工作区
- 至少有一个可用的iOS模拟器
</requirements>
Main Tasks
主要任务
0. Verify XcodeBuildMCP is Installed
0. 验证XcodeBuildMCP已安装
<check_mcp_installed>
First, check if XcodeBuildMCP tools are available.
Try calling:
mcp__xcodebuildmcp__list_simulators({})If the tool is not found or errors:
Tell the user:
markdown
**XcodeBuildMCP not installed**
Please install the XcodeBuildMCP server first:
\`\`\`bash
claude mcp add XcodeBuildMCP -- npx xcodebuildmcp@latest
\`\`\`
Then restart Claude Code and run `/xcode-test` again.Do NOT proceed until XcodeBuildMCP is confirmed working.
</check_mcp_installed>
<check_mcp_installed>
首先,检查XcodeBuildMCP工具是否可用。
尝试调用:
mcp__xcodebuildmcp__list_simulators({})如果未找到工具或出现错误:
告知用户:
markdown
**未安装XcodeBuildMCP**
请先安装XcodeBuildMCP服务器:
\`\`\`bash
claude mcp add XcodeBuildMCP -- npx xcodebuildmcp@latest
\`\`\`
然后重启Claude Code并重新运行 `/xcode-test`。在确认XcodeBuildMCP可正常工作前,请勿继续。
</check_mcp_installed>
1. Discover Project and Scheme
1. 发现项目与Scheme
<discover_project>
Find available projects:
mcp__xcodebuildmcp__discover_projs({})List schemes for the project:
mcp__xcodebuildmcp__list_schemes({ project_path: "/path/to/Project.xcodeproj" })If argument provided:
- Use the specified scheme name
- Or "current" to use the default/last-used scheme
</discover_project>
<discover_project>
查找可用项目:
mcp__xcodebuildmcp__discover_projs({})列出项目的Scheme:
mcp__xcodebuildmcp__list_schemes({ project_path: "/path/to/Project.xcodeproj" })如果提供了参数:
- 使用指定的Scheme名称
- 或使用"current"来使用默认/上次使用的Scheme
</discover_project>
2. Boot Simulator
2. 启动模拟器
<boot_simulator>
List available simulators:
mcp__xcodebuildmcp__list_simulators({})Boot preferred simulator (iPhone 15 Pro recommended):
mcp__xcodebuildmcp__boot_simulator({ simulator_id: "[uuid]" })Wait for simulator to be ready:
Check simulator state before proceeding with installation.
</boot_simulator>
<boot_simulator>
列出可用模拟器:
mcp__xcodebuildmcp__list_simulators({})启动首选模拟器(推荐iPhone 15 Pro):
mcp__xcodebuildmcp__boot_simulator({ simulator_id: "[uuid]" })等待模拟器就绪:
在继续安装前检查模拟器状态。
</boot_simulator>
3. Build the App
3. 构建应用
<build_app>
Build for iOS Simulator:
mcp__xcodebuildmcp__build_ios_sim_app({
project_path: "/path/to/Project.xcodeproj",
scheme: "[scheme_name]"
})Handle build failures:
- Capture build errors
- Create P1 todo for each build error
- Report to user with specific error details
On success:
- Note the built app path for installation
- Proceed to installation step
</build_app>
<build_app>
为iOS模拟器构建应用:
mcp__xcodebuildmcp__build_ios_sim_app({
project_path: "/path/to/Project.xcodeproj",
scheme: "[scheme_name]"
})处理构建失败:
- 捕获构建错误
- 为每个构建错误创建P1待办事项
- 向用户报告具体的错误详情
构建成功时:
- 记录已构建应用的路径以便安装
- 继续执行安装步骤
</build_app>
4. Install and Launch
4. 安装与启动
<install_launch>
Install app on simulator:
mcp__xcodebuildmcp__install_app_on_simulator({
app_path: "/path/to/built/App.app",
simulator_id: "[uuid]"
})Launch the app:
mcp__xcodebuildmcp__launch_app_on_simulator({
bundle_id: "[app.bundle.id]",
simulator_id: "[uuid]"
})Start capturing logs:
mcp__xcodebuildmcp__capture_sim_logs({
simulator_id: "[uuid]",
bundle_id: "[app.bundle.id]"
})</install_launch>
<install_launch>
在模拟器上安装应用:
mcp__xcodebuildmcp__install_app_on_simulator({
app_path: "/path/to/built/App.app",
simulator_id: "[uuid]"
})启动应用:
mcp__xcodebuildmcp__launch_app_on_simulator({
bundle_id: "[app.bundle.id]",
simulator_id: "[uuid]"
})开始捕获日志:
mcp__xcodebuildmcp__capture_sim_logs({
simulator_id: "[uuid]",
bundle_id: "[app.bundle.id]"
})</install_launch>
5. Test Key Screens
5. 测试关键页面
<test_screens>
For each key screen in the app:
Take screenshot:
mcp__xcodebuildmcp__take_screenshot({
simulator_id: "[uuid]",
filename: "screen-[name].png"
})Review screenshot for:
- UI elements rendered correctly
- No error messages visible
- Expected content displayed
- Layout looks correct
Check logs for errors:
mcp__xcodebuildmcp__get_sim_logs({ simulator_id: "[uuid]" })Look for:
- Crashes
- Exceptions
- Error-level log messages
- Failed network requests
</test_screens>
<test_screens>
针对应用中的每个关键页面:
截取屏幕截图:
mcp__xcodebuildmcp__take_screenshot({
simulator_id: "[uuid]",
filename: "screen-[name].png"
})检查截图内容:
- UI元素是否正确渲染
- 无错误消息显示
- 显示预期内容
- 布局是否正确
检查日志中的错误:
mcp__xcodebuildmcp__get_sim_logs({ simulator_id: "[uuid]" })重点关注:
- 崩溃
- 异常
- 错误级别的日志消息
- 失败的网络请求
</test_screens>
6. Human Verification (When Required)
6. 人工验证(必要时)
<human_verification>
Pause for human input when testing touches:
| Flow Type | What to Ask |
|---|---|
| Sign in with Apple | "Please complete Sign in with Apple on the simulator" |
| Push notifications | "Send a test push and confirm it appears" |
| In-app purchases | "Complete a sandbox purchase" |
| Camera/Photos | "Grant permissions and verify camera works" |
| Location | "Allow location access and verify map updates" |
Use AskUserQuestion:
markdown
**Human Verification Needed**
This test requires [flow type]. Please:
1. [Action to take on simulator]
2. [What to verify]
Did it work correctly?
1. Yes - continue testing
2. No - describe the issue</human_verification>
<human_verification>
测试涉及交互流程时暂停以等待人工输入:
| 流程类型 | 询问内容 |
|---|---|
| Apple登录 | "请在模拟器上完成Apple登录" |
| 推送通知 | "发送测试推送并确认其显示" |
| 内购 | "完成沙盒环境购买" |
| 相机/相册 | "授予权限并验证相机功能正常" |
| 定位 | "允许定位访问并验证地图更新" |
使用AskUserQuestion:
markdown
**需要人工验证**
本次测试需要[流程类型]。请:
1. [在模拟器上执行的操作]
2. [需要验证的内容]
操作是否正常?
1. 是 - 继续测试
2. 否 - 描述问题</human_verification>
7. Handle Failures
7. 处理测试失败
<failure_handling>
When a test fails:
-
Document the failure:
- Take screenshot of error state
- Capture console logs
- Note reproduction steps
-
Ask user how to proceed:markdown
**Test Failed: [screen/feature]** Issue: [description] Logs: [relevant error messages] How to proceed? 1. Fix now - I'll help debug and fix 2. Create todo - Add to todos/ for later 3. Skip - Continue testing other screens -
If "Fix now":
- Investigate the issue in code
- Propose a fix
- Rebuild and retest
-
If "Create todo":
- Create
{id}-pending-p1-xcode-{description}.md - Continue testing
- Create
</failure_handling>
<failure_handling>
测试失败时:
-
记录失败详情:
- 截取错误状态的截图
- 捕获控制台日志
- 记录复现步骤
-
询问用户后续处理方式:markdown
**测试失败:[页面/功能]** 问题:[描述] 日志:[相关错误消息] 如何继续? 1. 立即修复 - 我将协助调试和修复 2. 创建待办 - 添加到todos/以便后续处理 3. 跳过 - 继续测试其他页面 -
如果选择“立即修复”:
- 在代码中排查问题
- 提出修复方案
- 重新构建并测试
-
如果选择“创建待办”:
- 创建文件
{id}-pending-p1-xcode-{description}.md - 继续测试
- 创建
</failure_handling>
8. Test Summary
8. 测试总结
<test_summary>
After all tests complete, present summary:
markdown
undefined<test_summary>
所有测试完成后,呈现总结:
markdown
undefined📱 Xcode Test Results
📱 Xcode 测试结果
Project: [project name]
Scheme: [scheme name]
Simulator: [simulator name]
项目: [项目名称]
Scheme: [Scheme名称]
模拟器: [模拟器名称]
Build: ✅ Success / ❌ Failed
构建状态:✅ 成功 / ❌ 失败
Screens Tested: [count]
已测试页面:[数量]
| Screen | Status | Notes |
|---|---|---|
| Launch | ✅ Pass | |
| Home | ✅ Pass | |
| Settings | ❌ Fail | Crash on tap |
| Profile | ⏭️ Skip | Requires login |
| 页面 | 状态 | 备注 |
|---|---|---|
| 启动页 | ✅ 通过 | |
| 首页 | ✅ 通过 | |
| 设置页 | ❌ 失败 | 点击时崩溃 |
| 个人资料 | ⏭️ 跳过 | 需要登录 |
Console Errors: [count]
控制台错误:[数量]
- [List any errors found]
- [列出发现的所有错误]
Human Verifications: [count]
人工验证:[数量]
- Sign in with Apple: ✅ Confirmed
- Push notifications: ✅ Confirmed
- Apple登录:✅ 已确认
- 推送通知:✅ 已确认
Failures: [count]
失败项:[数量]
- Settings screen - crash on navigation
- 设置页 - 导航时崩溃
Created Todos: [count]
创建的待办:[数量]
006-pending-p1-xcode-settings-crash.md
006-pending-p1-xcode-settings-crash.md
Result: [PASS / FAIL / PARTIAL]
最终结果:[通过 / 失败 / 部分通过]
</test_summary>
</test_summary>9. Cleanup
9. 清理工作
<cleanup>
</cleanup>
After testing:
Stop log capture:
mcp__xcodebuildmcp__stop_log_capture({ simulator_id: "[uuid]" })Optionally shut down simulator:
mcp__xcodebuildmcp__shutdown_simulator({ simulator_id: "[uuid]" })<cleanup>
</cleanup>
测试完成后:
停止日志捕获:
mcp__xcodebuildmcp__stop_log_capture({ simulator_id: "[uuid]" })可选:关闭模拟器
mcp__xcodebuildmcp__shutdown_simulator({ simulator_id: "[uuid]" })Quick Usage Examples
快速使用示例
bash
undefinedbash
undefinedTest with default scheme
使用默认Scheme测试
/xcode-test
/xcode-test
Test specific scheme
测试指定Scheme
/xcode-test MyApp-Debug
/xcode-test MyApp-Debug
Test after making changes
修改代码后测试
/xcode-test current
undefined/xcode-test current
undefinedIntegration with /ce:review
与/ce:review的集成
When reviewing PRs that touch iOS code, the command can spawn this as a subagent:
/ce:reviewTask general-purpose("Run /xcode-test for scheme [name]. Build, install on simulator, test key screens, check for crashes.")在审查涉及iOS代码的PR时,命令可以将本命令作为子代理调用:
/ce:reviewTask general-purpose("Run /xcode-test for scheme [name]. Build, install on simulator, test key screens, check for crashes.")