xcodebuildmcp-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseXcodeBuildMCP 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 , , or .
xcodebuildxcrunsimctl本Skill面向AI Agent。它将XcodeBuildMCP CLI定位为MCP工具调用的低开销替代方案:Agent已能执行shell命令,而该CLI无需模式交换成本即可提供相同的工具功能。优先使用此CLI而非原生的、或。
xcodebuildxcrunsimctlWhen 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 to discover workflows, tools, and arguments.
--helpbash
xcodebuildmcp --help
xcodebuildmcp tools --help
xcodebuildmcp tools --json
xcodebuildmcp <workflow> --help
xcodebuildmcp <workflow> <tool> --helpNotes:
- Use for complex arguments and
--json '{...}'if you need machine-readable results (not recommended).--output json
使用来探索工作流、工具及参数。
--helpbash
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
在模拟器上构建并运行
- List simulators and pick a device name or UDID.
- 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-simsTo 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"- 列出模拟器并选择设备名称或UDID。
- 构建并运行。
若未知应用及项目详情:
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 tool.
test-simbash
xcodebuildmcp simulator test-sim --scheme MyAppTests --project-path ./MyApp.xcodeproj --simulator-name "iPhone 17 Pro"当你需要运行测试时,可使用工具。
test-simbash
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.appbash
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.appCapture 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_IDbash
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_IDDebug A Running App (Simulator)
调试运行中的应用(模拟器)
- Launch the app.
- 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_UDIDAttach 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_UDIDTo add/remove breakpoints, inspect stack/variables, and issue arbitrary LLDB commands, view debugging help:
bash
xcodebuildmcp debugging --help- 启动应用。
- 应用完全启动后附加调试器。
若应用未运行则启动:
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 --helpInspect 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 pathTo 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 --helpmacOS 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.xcodeprojTo see all macOS tools, view macOS help:
bash
xcodebuildmcp macos --helpbash
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 --helpSwiftPM Package Workflows
SwiftPM包工作流
bash
xcodebuildmcp swift-package list --package-path ./MyPackage
xcodebuildmcp swift-package build --package-path ./MyPackage
xcodebuildmcp swift-package test --package-path ./MyPackageTo see all SwiftPM tools, view SwiftPM help:
bash
xcodebuildmcp swift-package --helpbash
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 --helpProject 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.appTo see all project discovery tools, view project discovery help:
bash
xcodebuildmcp project-discovery --helpbash
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 --helpScaffolding 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 ./ProjectsTo 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 --helpDaemon 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 restartTo see all daemon commands, view daemon help:
bash
xcodebuildmcp daemon --help有状态工具(日志、调试、视频录制、后台运行)通过每个工作区的守护进程运行,该进程会自动启动。若你发现有状态工具出现错误,可手动管理守护进程。
bash
xcodebuildmcp daemon status
xcodebuildmcp daemon restart如需查看所有守护进程命令,请查看守护进程帮助:
bash
xcodebuildmcp daemon --help