ce-test-xcode
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseXcode Test Skill
Xcode测试技能
Build, install, and test iOS apps on the simulator using XcodeBuildMCP. Captures screenshots, logs, and verifies app behavior.
使用XcodeBuildMCP在模拟器上构建、安装并测试iOS应用。可捕获截图、日志并验证应用行为。
Prerequisites
前提条件
- Xcode installed with command-line tools
- XcodeBuildMCP MCP server connected
- Valid Xcode project or workspace
- At least one iOS Simulator available
- 已安装Xcode及命令行工具
- 已连接XcodeBuildMCP MCP服务器
- 有效的Xcode项目或工作区
- 至少有一个可用的iOS模拟器
Workflow
工作流程
0. Verify XcodeBuildMCP is Available
0. 验证XcodeBuildMCP可用
Check that the XcodeBuildMCP MCP server is connected by calling its tool.
list_simulatorsMCP tool names vary by platform:
- Claude Code:
mcp__xcodebuildmcp__list_simulators - Other platforms: use the equivalent MCP tool call for the server's
XcodeBuildMCPmethodlist_simulators
If the tool is not found or errors, inform the user they need to add the XcodeBuildMCP MCP server:
XcodeBuildMCP not installed
Install via Homebrew:
brew tap getsentry/xcodebuildmcp && brew install xcodebuildmcp
Or via npx (no global install needed):
npx -y xcodebuildmcp@latest mcp
Then add "XcodeBuildMCP" as an MCP server in your agent configuration
and restart your agent.Do NOT proceed until XcodeBuildMCP is confirmed working.
通过调用其工具,检查XcodeBuildMCP MCP服务器是否已连接。
list_simulatorsMCP工具名称因平台而异:
- Claude Code:
mcp__xcodebuildmcp__list_simulators - 其他平台:使用对应MCP工具调用XcodeBuildMCP服务器的方法
list_simulators
若未找到工具或出现错误,告知用户需添加XcodeBuildMCP MCP服务器:
XcodeBuildMCP not installed
Install via Homebrew:
brew tap getsentry/xcodebuildmcp && brew install xcodebuildmcp
Or via npx (no global install needed):
npx -y xcodebuildmcp@latest mcp
Then add "XcodeBuildMCP" as an MCP server in your agent configuration
and restart your agent.在确认XcodeBuildMCP正常工作前,请勿继续操作。
1. Discover Project and Scheme
1. 发现项目与Scheme
Call XcodeBuildMCP's tool to find available projects, then with the project path to get available schemes.
discover_projslist_schemesIf an argument was provided, use that scheme name. If "current", use the default/last-used scheme.
调用XcodeBuildMCP的工具查找可用项目,然后传入项目路径调用获取可用Scheme。
discover_projslist_schemes若提供了参数,则使用该Scheme名称;若为"current",则使用默认/最近使用的Scheme。
2. Boot Simulator
2. 启动模拟器
Call to find available simulators. Boot the preferred simulator (iPhone 15 Pro recommended) using with the simulator's UUID.
list_simulatorsboot_simulatorWait for the simulator to be ready before proceeding.
调用查找可用模拟器。使用并传入模拟器UUID,启动首选模拟器(推荐iPhone 15 Pro)。
list_simulatorsboot_simulator等待模拟器准备就绪后再继续。
3. Build the App
3. 构建应用
Call with the project path and scheme name.
build_ios_sim_appOn failure:
- Capture build errors
- Report to user with specific error details
On success:
- Note the built app path for installation
- Proceed to step 4
传入项目路径和Scheme名称,调用。
build_ios_sim_app构建失败时:
- 捕获构建错误
- 向用户报告具体错误详情
构建成功时:
- 记录已构建应用的路径以便安装
- 进入步骤4
4. Install and Launch
4. 安装与启动
- Call with the built app path and simulator UUID
install_app_on_simulator - Call with the bundle ID and simulator UUID
launch_app_on_simulator - Call with the simulator UUID and bundle ID to start log capture
capture_sim_logs
- 传入已构建应用路径和模拟器UUID,调用
install_app_on_simulator - 传入Bundle ID和模拟器UUID,调用
launch_app_on_simulator - 传入模拟器UUID和Bundle ID,调用开始日志捕获
capture_sim_logs
5. Test Key Screens
5. 测试关键界面
For each key screen in the app:
Take screenshot:
Call with the simulator UUID and a descriptive filename (e.g., ).
take_screenshotscreen-home.pngReview screenshot for:
- UI elements rendered correctly
- No error messages visible
- Expected content displayed
- Layout looks correct
Check logs for errors:
Call with the simulator UUID. Look for:
get_sim_logs- Crashes
- Exceptions
- Error-level log messages
- Failed network requests
Known automation limitation — SwiftUI Text links:
Simulated taps (via XcodeBuildMCP or any simulator automation tool) do not trigger gesture recognizers on SwiftUI views with inline links. Taps report success but have no effect. This is a platform limitation — inline links are not exposed as separate elements in the accessibility tree. When a tap on a Text link has no visible effect, prompt the user to tap manually in the simulator. If the target URL is known, can open it directly as a fallback.
TextAttributedStringxcrun simctl openurl <device> <URL>针对应用中的每个关键界面:
截取屏幕截图:
传入模拟器UUID和描述性文件名(如),调用。
screen-home.pngtake_screenshot检查截图内容:
- UI元素渲染正确
- 无可见错误提示
- 显示预期内容
- 布局正常
检查日志中的错误:
传入模拟器UUID,调用。查找以下内容:
get_sim_logs- 崩溃信息
- 异常情况
- 错误级别的日志消息
- 失败的网络请求
已知自动化限制 — SwiftUI Text链接:
通过XcodeBuildMCP或任何模拟器自动化工具进行的模拟点击,无法触发带有内嵌链接的SwiftUI 视图上的手势识别器。点击操作会返回成功,但无实际效果。这是平台限制——内嵌链接在无障碍树中未被暴露为独立元素。当点击Text链接无可见效果时,请提示用户在模拟器中手动点击。若已知目标URL,可直接使用作为替代方案打开链接。
AttributedStringTextxcrun simctl openurl <device> <URL>6. Human Verification (When Required)
6. 人工验证(必要时)
Pause for human input when testing touches flows that require device interaction.
| 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" |
| SwiftUI Text links | "Please tap on [element description] manually — automated taps cannot trigger inline text links" |
Ask the user using the platform's blocking question tool: in Claude Code (call with first if its schema isn't loaded), in Codex, in Gemini, in Pi (requires the extension). Fall back to numbered options in chat only when no blocking tool exists in the harness or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip the question:
AskUserQuestionToolSearchselect:AskUserQuestionrequest_user_inputask_userask_userpi-ask-userHuman 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当测试需要设备交互的触控流程时,暂停等待用户输入。
| 流程类型 | 询问内容 |
|---|---|
| 使用Apple登录 | "请在模拟器上完成使用Apple登录" |
| 推送通知 | "发送测试推送并确认其显示" |
| 内购 | "完成沙盒购买" |
| 相机/相册 | "授予权限并验证相机功能正常" |
| 定位 | "允许定位访问并验证地图更新" |
| SwiftUI Text链接 | "请手动点击[元素描述]——自动化点击无法触发内嵌文本链接" |
使用平台的阻塞式提问工具询问用户:Claude Code中使用(若未加载其 schema,先调用并传入),Codex中使用,Gemini中使用,Pi中使用(需扩展)。仅当工具集中无阻塞式工具或调用出错时(如Codex编辑模式),才在聊天中使用编号选项作为 fallback——而非因需要加载schema而使用。切勿跳过提问:
AskUserQuestionToolSearchselect:AskUserQuestionrequest_user_inputask_userask_userpi-ask-userHuman 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 issue7. Handle Failures
7. 处理失败情况
When a test fails:
-
Document the failure:
- Take screenshot of error state
- Capture console logs
- Note reproduction steps
-
Ask the user how to proceed:
Test Failed: [screen/feature] Issue: [description] Logs: [relevant error messages] How to proceed? 1. Fix now - debug, propose a fix, rebuild and retest 2. Skip - continue testing other screens -
If "Fix now": investigate, propose a fix, rebuild and retest
-
If "Skip": log as skipped, continue
测试失败时:
-
记录失败情况:
- 截取错误状态的截图
- 捕获控制台日志
- 记录复现步骤
-
询问用户后续操作:
Test Failed: [screen/feature] Issue: [description] Logs: [relevant error messages] How to proceed? 1. Fix now - debug, propose a fix, rebuild and retest 2. Skip - continue testing other screens -
若选择"Fix now": 排查问题、提出修复方案、重新构建并测试
-
若选择"Skip": 记录为跳过,继续测试
8. Test Summary
8. 测试总结
After all tests complete, present a summary:
markdown
undefined所有测试完成后,呈现总结:
markdown
undefinedXcode 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
- 设置页 - 导航时崩溃
Result: [PASS / FAIL / PARTIAL]
最终结果:[通过 / 失败 / 部分通过]
undefinedundefined9. Cleanup
9. 清理
After testing:
- Call with the simulator UUID
stop_log_capture - Optionally call with the simulator UUID
shutdown_simulator
测试完成后:
- 传入模拟器UUID,调用
stop_log_capture - 可选:传入模拟器UUID,调用
shutdown_simulator
Quick Usage Examples
快速使用示例
bash
undefinedbash
undefinedTest with default scheme
使用默认Scheme测试
/ce-test-xcode
/ce-test-xcode
Test specific scheme
测试指定Scheme
/ce-test-xcode MyApp-Debug
/ce-test-xcode MyApp-Debug
Test after making changes
修改代码后测试
/ce-test-xcode current
undefined/ce-test-xcode current
undefinedIntegration with ce-code-review
与ce-code-review集成
When reviewing PRs that touch iOS code, the workflow can spawn an agent to run this skill, build on the simulator, test key screens, and check for crashes.
ce-code-review当审查涉及iOS代码的PR时,工作流可生成一个Agent来运行此技能,在模拟器上构建应用、测试关键界面并检查崩溃情况。
ce-code-review