用途:在用户要求构建 iOS 应用、在模拟器运行、测试 iOS、录制模拟器视频、重置应用或引导流程,或需要 Xcode 构建时使用。
主要能力:用 xcodebuild 与 xcrun simctl 发现工程结构、查找与启动模拟器、构建并安装启动应用、运行单元/UI 测试并可选代码覆盖率、截图与录屏、卸载或抹除模拟器以重置应用状态,也支持 Tuist 项目。
使用方式:先列出 scheme(xcodebuild -list 或 xcodebuild -workspace App.xcworkspace -list),再查模拟器(xcrun simctl list devices,或取已启动 UDID:xcrun simctl list devices booted --json | jq -r '.devices[][] | select(.state == "Booted") | .udid')。按需启动(xcrun simctl boot $UDID),构建(xcodebuild -workspace App.xcworkspace -scheme App -destination "platform=iOS Simulator,id=$UDID" -derivedDataPath ./DerivedData build),安装启动(xcrun simctl install $UDID "$APP_PATH",xcrun simctl launch $UDID $BUNDLE_ID,可加 --console)。重置用 xcrun simctl uninstall 后重装启动,彻底重置用 xcrun simctl erase $UDID。录屏 xcrun simctl io $UDID recordVideo output.mp4 &,停止须用 kill -2;截图 xcrun simctl io $UDID screenshot screenshot.png。测试用 xcodebuild test,可用 -only-testing:AppTests/LoginTests 指定类,加 -enableCodeCoverage YES 生成覆盖率。Tuist 项目先 mise exec -- tuist install 与 mise exec -- tuist generate。若可用 XcodeBuildMCP 工具,优先用于工程发现、构建与模拟器管理,否则回退 CLI。
限制与排错:无 scheme 时先用 -list 确认;提示找不到模拟器时核对 UDID 并用 xcrun simctl list devices available;应用无法启动时检查 Info.plist 中 bundle ID,并用 --console 查看错误;录屏需优雅终止(SIGINT),不可用 kill -9。完整命令文档见 CLI_REFERENCE.md。收费、价格、平台支持与效果等资料暂未提供。