xcodebuildmcp-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

XcodeBuildMCP CLI

XcodeBuildMCP CLI

This skill is for AI agents. It positions the XcodeBuildMCP CLI as a low‑overhead alternative to MCP tool calls: agents can already run shell commands, and the CLI exposes the same tool surface without the schema‑exchange cost. Prefer the CLI over raw
xcodebuild
,
xcrun
, or
simctl
.
本Skill面向AI Agent。它将XcodeBuildMCP CLI定位为MCP工具调用的低开销替代方案:Agent已能执行shell命令,而该CLI无需模式交换成本即可提供相同的工具功能。优先使用此CLI而非原生的
xcodebuild
xcrun
simctl

When To Use This CLI (Capabilities And Workflows)

何时使用此CLI(功能与工作流)

  • When you need build/test/run/debugging/logging/UI automation capabilities.
  • When you want simulator/device management capabilities.
  • When you want AI optimized tools and tool responses.
  • When you need project discovery capabilities (schemes, bundle IDs, app paths).
  • 当你需要构建/测试/运行/调试/日志/UI自动化功能时。
  • 当你需要模拟器/设备管理功能时。
  • 当你需要AI优化的工具及工具响应时。
  • 当你需要项目发现功能(Scheme、Bundle ID、应用路径)时。

Command Discovery

命令发现

Use
--help
to discover workflows, tools, and arguments.
bash
xcodebuildmcp --help
xcodebuildmcp tools --help
xcodebuildmcp tools --json
xcodebuildmcp <workflow> --help
xcodebuildmcp <workflow> <tool> --help
Notes:
  • Use
    --json '{...}'
    for complex arguments and
    --output json
    if you need machine-readable results (not recommended).
使用
--help
来探索工作流、工具及参数。
bash
xcodebuildmcp --help
xcodebuildmcp tools --help
xcodebuildmcp tools --json
xcodebuildmcp <workflow> --help
xcodebuildmcp <workflow> <tool> --help
注意:
  • 复杂参数使用
    --json '{...}'
    ,若需要机器可读结果可使用
    --output json
    (不推荐)。

Common Workflows

常见工作流

Build And Run On Simulator

在模拟器上构建并运行

  1. List simulators and pick a device name or UDID.
  2. Build and run.
If app and project details are not known:
bash
xcodebuildmcp simulator discover-projs --workspace-root .
xcodebuildmcp simulator list-schemes --project-path ./MyApp.xcodeproj
xcodebuildmcp simulator list-sims
To build, install and launch the app in one command:
bash
xcodebuildmcp simulator build-run-sim --scheme MyApp --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"
  1. 列出模拟器并选择设备名称或UDID。
  2. 构建并运行。
若未知应用及项目详情:
bash
xcodebuildmcp simulator discover-projs --workspace-root .
xcodebuildmcp simulator list-schemes --project-path ./MyApp.xcodeproj
xcodebuildmcp simulator list-sims
一键构建、安装并启动应用:
bash
xcodebuildmcp simulator build-run-sim --scheme MyApp --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"

Build only

仅构建

When you only need to check that there are no build errors, you can build without running the app.
bash
xcodebuildmcp simulator build-sim --scheme MyApp --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"
当你只需检查是否存在构建错误时,可仅构建而不运行应用。
bash
xcodebuildmcp simulator build-sim --scheme MyApp --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"

Run Tests

运行测试

When you need to run tests, you can do so with the
test-sim
tool.
bash
xcodebuildmcp simulator test-sim --scheme MyAppTests --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"
当你需要运行测试时,可使用
test-sim
工具。
bash
xcodebuildmcp simulator test-sim --scheme MyAppTests --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"

Install And Launch On Physical Device

在物理设备上安装并启动

bash
xcodebuildmcp device list-devices
xcodebuildmcp device build-device --scheme MyApp --project-path ./MyApp.xcodeproj
xcodebuildmcp device get-device-app-path --scheme MyApp --project-path ./MyApp.xcodeproj
xcodebuildmcp device get-app-bundle-id --app-path /path/to/MyApp.app
xcodebuildmcp device install-app-device --device-id DEVICE_UDID --app-path /path/to/MyApp.app
xcodebuildmcp device launch-app-device --device-id DEVICE_UDID --bundle-id io.sentry.MyApp --app-path /path/to/MyApp.app
bash
xcodebuildmcp device list-devices
xcodebuildmcp device build-device --scheme MyApp --project-path ./MyApp.xcodeproj
xcodebuildmcp device get-device-app-path --scheme MyApp --project-path ./MyApp.xcodeproj
xcodebuildmcp device get-app-bundle-id --app-path /path/to/MyApp.app
xcodebuildmcp device install-app-device --device-id DEVICE_UDID --app-path /path/to/MyApp.app
xcodebuildmcp device launch-app-device --device-id DEVICE_UDID --bundle-id io.sentry.MyApp --app-path /path/to/MyApp.app

Capture Logs On Simulator

在模拟器上捕获日志

bash
xcodebuildmcp logging start-sim-log-cap --simulator-id SIMULATOR_UDID --bundle-id io.sentry.MyApp
xcodebuildmcp logging stop-sim-log-cap --log-session-id LOG_SESSION_ID
bash
xcodebuildmcp logging start-sim-log-cap --simulator-id SIMULATOR_UDID --bundle-id io.sentry.MyApp
xcodebuildmcp logging stop-sim-log-cap --log-session-id LOG_SESSION_ID

Debug A Running App (Simulator)

调试运行中的应用(模拟器)

  1. Launch the app.
  2. Attach the debugger after the app is fully launched.
Launch if not already running:
bash
xcodebuildmcp simulator launch-app-sim --bundle-id io.sentry.MyApp --simulator-id SIMULATOR_UDID
Attach the debugger:
It's generally a good idea to wait for 1-2s for the app to fully launch before attaching the debugger.
bash
xcodebuildmcp debugging debug-attach-sim --bundle-id io.sentry.MyApp --simulator-id SIMULATOR_UDID
To add/remove breakpoints, inspect stack/variables, and issue arbitrary LLDB commands, view debugging help:
bash
xcodebuildmcp debugging --help
  1. 启动应用。
  2. 应用完全启动后附加调试器。
若应用未运行则启动:
bash
xcodebuildmcp simulator launch-app-sim --bundle-id io.sentry.MyApp --simulator-id SIMULATOR_UDID
附加调试器:
通常建议等待1-2秒,待应用完全启动后再附加调试器。
bash
xcodebuildmcp debugging debug-attach-sim --bundle-id io.sentry.MyApp --simulator-id SIMULATOR_UDID
如需添加/移除断点、检查堆栈/变量或执行任意LLDB命令,请查看调试帮助:
bash
xcodebuildmcp debugging --help

Inspect UI And Automate Input

检查UI并自动化输入

Snapshot UI accessibility tree, tap/swipe/type, and capture screenshots:
bash
xcodebuildmcp ui-automation snapshot-ui --simulator-id SIMULATOR_UDID
xcodebuildmcp ui-automation tap --simulator-id SIMULATOR_UDID --x 200 --y 400
xcodebuildmcp ui-automation type-text --simulator-id SIMULATOR_UDID --text "hello"
xcodebuildmcp ui-automation screenshot --simulator-id SIMULATOR_UDID --return-format path
To see all UI automation tools, view UI automation help:
bash
xcodebuildmcp ui-automation --help
快照UI无障碍树、点击/滑动/输入文本、捕获截图:
bash
xcodebuildmcp ui-automation snapshot-ui --simulator-id SIMULATOR_UDID
xcodebuildmcp ui-automation tap --simulator-id SIMULATOR_UDID --x 200 --y 400
xcodebuildmcp ui-automation type-text --simulator-id SIMULATOR_UDID --text "hello"
xcodebuildmcp ui-automation screenshot --simulator-id SIMULATOR_UDID --return-format path
如需查看所有UI自动化工具,请查看UI自动化帮助:
bash
xcodebuildmcp ui-automation --help

macOS App Build/Run

macOS应用构建/运行

bash
xcodebuildmcp macos build-macos --scheme MyMacApp --project-path ./MyMacApp.xcodeproj
xcodebuildmcp macos build-run-macos --scheme MyMacApp --project-path ./MyMacApp.xcodeproj
To see all macOS tools, view macOS help:
bash
xcodebuildmcp macos --help
bash
xcodebuildmcp macos build-macos --scheme MyMacApp --project-path ./MyMacApp.xcodeproj
xcodebuildmcp macos build-run-macos --scheme MyMacApp --project-path ./MyMacApp.xcodeproj
如需查看所有macOS工具,请查看macOS帮助:
bash
xcodebuildmcp macos --help

SwiftPM Package Workflows

SwiftPM包工作流

bash
xcodebuildmcp swift-package list --package-path ./MyPackage
xcodebuildmcp swift-package build --package-path ./MyPackage
xcodebuildmcp swift-package test --package-path ./MyPackage
To see all SwiftPM tools, view SwiftPM help:
bash
xcodebuildmcp swift-package --help
bash
xcodebuildmcp swift-package list --package-path ./MyPackage
xcodebuildmcp swift-package build --package-path ./MyPackage
xcodebuildmcp swift-package test --package-path ./MyPackage
如需查看所有SwiftPM工具,请查看SwiftPM帮助:
bash
xcodebuildmcp swift-package --help

Project Discovery

项目发现

bash
xcodebuildmcp project-discovery discover-projs --workspace-root .
xcodebuildmcp project-discovery list-schemes --project-path ./MyApp.xcodeproj
xcodebuildmcp project-discovery get-app-bundle-id --app-path ./Build/MyApp.app
To see all project discovery tools, view project discovery help:
bash
xcodebuildmcp project-discovery --help
bash
xcodebuildmcp project-discovery discover-projs --workspace-root .
xcodebuildmcp project-discovery list-schemes --project-path ./MyApp.xcodeproj
xcodebuildmcp project-discovery get-app-bundle-id --app-path ./Build/MyApp.app
如需查看所有项目发现工具,请查看项目发现帮助:
bash
xcodebuildmcp project-discovery --help

Scaffolding new projects

新项目脚手架

It's worth viewing the --help for the scaffolding tools to see the available options. Here are some minimal examples:
bash
xcodebuildmcp project-scaffolding scaffold-ios-project --project-name MyApp --output-path ./Projects
xcodebuildmcp project-scaffolding scaffold-macos-project --project-name MyMacApp --output-path ./Projects
To see all project scaffolding tools, view project scaffolding help:
bash
xcodebuildmcp project-scaffolding --help
建议查看脚手架工具的--help以了解可用选项。 以下是一些基础示例:
bash
xcodebuildmcp project-scaffolding scaffold-ios-project --project-name MyApp --output-path ./Projects
xcodebuildmcp project-scaffolding scaffold-macos-project --project-name MyMacApp --output-path ./Projects
如需查看所有项目脚手架工具,请查看项目脚手架帮助:
bash
xcodebuildmcp project-scaffolding --help

Daemon Notes (Stateful Tools)

守护进程说明(有状态工具)

Stateful tools (logs, debug, video recording, background run) go through a per-workspace daemon that auto-starts, if you find you are getting errors with the stateful tools, you can manage the daemon process manually.
bash
xcodebuildmcp daemon status
xcodebuildmcp daemon restart
To see all daemon commands, view daemon help:
bash
xcodebuildmcp daemon --help
有状态工具(日志、调试、视频录制、后台运行)通过每个工作区的守护进程运行,该进程会自动启动。若你发现有状态工具出现错误,可手动管理守护进程。
bash
xcodebuildmcp daemon status
xcodebuildmcp daemon restart
如需查看所有守护进程命令,请查看守护进程帮助:
bash
xcodebuildmcp daemon --help