ce-test-xcode

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Xcode 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
list_simulators
tool.
MCP tool names vary by platform:
  • Claude Code:
    mcp__xcodebuildmcp__list_simulators
  • Other platforms: use the equivalent MCP tool call for the
    XcodeBuildMCP
    server's
    list_simulators
    method
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.
通过调用其
list_simulators
工具,检查XcodeBuildMCP MCP服务器是否已连接。
MCP工具名称因平台而异:
  • 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
discover_projs
tool to find available projects, then
list_schemes
with the project path to get available schemes.
If an argument was provided, use that scheme name. If "current", use the default/last-used scheme.
调用XcodeBuildMCP的
discover_projs
工具查找可用项目,然后传入项目路径调用
list_schemes
获取可用Scheme。
若提供了参数,则使用该Scheme名称;若为"current",则使用默认/最近使用的Scheme。

2. Boot Simulator

2. 启动模拟器

Call
list_simulators
to find available simulators. Boot the preferred simulator (iPhone 15 Pro recommended) using
boot_simulator
with the simulator's UUID.
Wait for the simulator to be ready before proceeding.
调用
list_simulators
查找可用模拟器。使用
boot_simulator
并传入模拟器UUID,启动首选模拟器(推荐iPhone 15 Pro)。
等待模拟器准备就绪后再继续。

3. Build the App

3. 构建应用

Call
build_ios_sim_app
with the project path and scheme name.
On 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. 安装与启动

  1. Call
    install_app_on_simulator
    with the built app path and simulator UUID
  2. Call
    launch_app_on_simulator
    with the bundle ID and simulator UUID
  3. Call
    capture_sim_logs
    with the simulator UUID and bundle ID to start log capture
  1. 传入已构建应用路径和模拟器UUID,调用
    install_app_on_simulator
  2. 传入Bundle ID和模拟器UUID,调用
    launch_app_on_simulator
  3. 传入模拟器UUID和Bundle ID,调用
    capture_sim_logs
    开始日志捕获

5. Test Key Screens

5. 测试关键界面

For each key screen in the app:
Take screenshot: Call
take_screenshot
with the simulator UUID and a descriptive filename (e.g.,
screen-home.png
).
Review screenshot for:
  • UI elements rendered correctly
  • No error messages visible
  • Expected content displayed
  • Layout looks correct
Check logs for errors: Call
get_sim_logs
with the simulator UUID. Look for:
  • 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
Text
views with inline
AttributedString
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,
xcrun simctl openurl <device> <URL>
can open it directly as a fallback.
针对应用中的每个关键界面:
截取屏幕截图: 传入模拟器UUID和描述性文件名(如
screen-home.png
),调用
take_screenshot
检查截图内容:
  • UI元素渲染正确
  • 无可见错误提示
  • 显示预期内容
  • 布局正常
检查日志中的错误: 传入模拟器UUID,调用
get_sim_logs
。查找以下内容:
  • 崩溃信息
  • 异常情况
  • 错误级别的日志消息
  • 失败的网络请求
已知自动化限制 — SwiftUI Text链接: 通过XcodeBuildMCP或任何模拟器自动化工具进行的模拟点击,无法触发带有内嵌
AttributedString
链接的SwiftUI
Text
视图上的手势识别器。点击操作会返回成功,但无实际效果。这是平台限制——内嵌链接在无障碍树中未被暴露为独立元素。当点击Text链接无可见效果时,请提示用户在模拟器中手动点击。若已知目标URL,可直接使用
xcrun simctl openurl <device> <URL>
作为替代方案打开链接。

6. Human Verification (When Required)

6. 人工验证(必要时)

Pause for human input when testing touches flows that require device interaction.
Flow TypeWhat 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:
AskUserQuestion
in Claude Code (call
ToolSearch
with
select:AskUserQuestion
first if its schema isn't loaded),
request_user_input
in Codex,
ask_user
in Gemini,
ask_user
in Pi (requires the
pi-ask-user
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:
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
当测试需要设备交互的触控流程时,暂停等待用户输入。
流程类型询问内容
使用Apple登录"请在模拟器上完成使用Apple登录"
推送通知"发送测试推送并确认其显示"
内购"完成沙盒购买"
相机/相册"授予权限并验证相机功能正常"
定位"允许定位访问并验证地图更新"
SwiftUI Text链接"请手动点击[元素描述]——自动化点击无法触发内嵌文本链接"
使用平台的阻塞式提问工具询问用户:Claude Code中使用
AskUserQuestion
(若未加载其 schema,先调用
ToolSearch
并传入
select:AskUserQuestion
),Codex中使用
request_user_input
,Gemini中使用
ask_user
,Pi中使用
ask_user
(需
pi-ask-user
扩展)。仅当工具集中无阻塞式工具或调用出错时(如Codex编辑模式),才在聊天中使用编号选项作为 fallback——而非因需要加载schema而使用。切勿跳过提问:
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

7. Handle Failures

7. 处理失败情况

When a test fails:
  1. Document the failure:
    • Take screenshot of error state
    • Capture console logs
    • Note reproduction steps
  2. 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
  3. If "Fix now": investigate, propose a fix, rebuild and retest
  4. If "Skip": log as skipped, continue
测试失败时:
  1. 记录失败情况:
    • 截取错误状态的截图
    • 捕获控制台日志
    • 记录复现步骤
  2. 询问用户后续操作:
    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
  3. 若选择"Fix now": 排查问题、提出修复方案、重新构建并测试
  4. 若选择"Skip": 记录为跳过,继续测试

8. Test Summary

8. 测试总结

After all tests complete, present a summary:
markdown
undefined
所有测试完成后,呈现总结:
markdown
undefined

Xcode Test Results

Xcode测试结果

Project: [project name] Scheme: [scheme name] Simulator: [simulator name]
项目: [项目名称] Scheme: [Scheme名称] 模拟器: [模拟器名称]

Build: Success / Failed

构建状态:成功 / 失败

Screens Tested: [count]

已测试界面数量:[数量]

ScreenStatusNotes
LaunchPass
HomePass
SettingsFailCrash on tap
ProfileSkipRequires 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]

最终结果:[通过 / 失败 / 部分通过]

undefined
undefined

9. Cleanup

9. 清理

After testing:
  1. Call
    stop_log_capture
    with the simulator UUID
  2. Optionally call
    shutdown_simulator
    with the simulator UUID
测试完成后:
  1. 传入模拟器UUID,调用
    stop_log_capture
  2. 可选:传入模拟器UUID,调用
    shutdown_simulator

Quick Usage Examples

快速使用示例

bash
undefined
bash
undefined

Test 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
undefined

Integration with ce-code-review

与ce-code-review集成

When reviewing PRs that touch iOS code, the
ce-code-review
workflow can spawn an agent to run this skill, build on the simulator, test key screens, and check for crashes.
当审查涉及iOS代码的PR时,
ce-code-review
工作流可生成一个Agent来运行此技能,在模拟器上构建应用、测试关键界面并检查崩溃情况。