xcode-build by pzep1/xcode-build-skill
npx skills add https://github.com/pzep1/xcode-build-skill --skill xcode-build使用原生 Xcode CLI 工具而非 MCP 服务器来构建和管理 iOS/macOS 项目。
在以下情况下使用此技能:
偏好:始终使用直接的 CLI 命令(xcodebuild、xcrun simctl)而非 XcodeBuildMCP 工具。
# 列出工作空间中的方案
xcodebuild -workspace /path/to/App.xcworkspace -list
# 列出项目中的方案
xcodebuild -project /path/to/App.xcodeproj -list
# 显示构建设置
xcodebuild -workspace /path/to/App.xcworkspace -scheme AppScheme -showBuildSettings
# 列出所有模拟器
xcrun simctl list devices
# 以 JSON 格式列出(便于解析)
xcrun simctl list devices --json
# 仅列出可用的模拟器
xcrun simctl list devices available
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 首先获取模拟器 UUID
UDID=$(xcrun simctl list devices --json | jq -r '.devices | .[].[] | select(.name=="iPhone 16 Pro") | .udid' | head -1)
# 构建
xcodebuild \
-workspace /path/to/App.xcworkspace \
-scheme AppScheme \
-destination "platform=iOS Simulator,id=$UDID" \
-configuration Debug \
-derivedDataPath /tmp/build \
build
# 查找构建的 .app 文件
APP_PATH=$(find /tmp/build -name "*.app" -type d | head -1)
# 安装到模拟器
xcrun simctl install $UDID "$APP_PATH"
# 启动应用
xcrun simctl launch $UDID com.your.bundleid
xcrun simctl io $UDID screenshot /tmp/screenshot.png
有关完整的命令文档,请参阅:
xcodebuild 和 xcrun simctl 命令参考# 1. 启动模拟器
xcrun simctl boot $UDID 2>/dev/null || true
# 2. 构建
xcodebuild -workspace App.xcworkspace -scheme App \
-destination "platform=iOS Simulator,id=$UDID" \
-derivedDataPath /tmp/build build
# 3. 查找并安装应用
APP=$(find /tmp/build -name "*.app" -type d | head -1)
xcrun simctl install $UDID "$APP"
# 4. 启动并输出控制台信息
xcrun simctl launch --console $UDID com.bundle.id
# 流式传输应用日志(在后台运行)
/usr/bin/log stream \
--predicate 'processImagePath CONTAINS[cd] "AppName"' \
--style json &
LOG_PID=$!
# ... 与应用交互 ...
# 停止日志记录
kill $LOG_PID
# 单元测试
xcodebuild -workspace App.xcworkspace -scheme App \
-destination "platform=iOS Simulator,id=$UDID" \
test
# 特定测试类
xcodebuild -workspace App.xcworkspace -scheme App \
-destination "platform=iOS Simulator,id=$UDID" \
-only-testing "AppTests/MyTestClass" \
test
对于点击、输入和 UI 元素查询,请使用 XCUITest(Apple 的原生 UI 测试框架)。
这比基于 MCP 的自动化更强大,因为:
完整的模式请参阅 XCUITEST_GUIDE.md。
快速示例:
// 在 UI 测试文件中
func testLogin() {
let app = XCUIApplication()
app.launch()
// 在文本字段中输入
app.textFields["email"].tap()
app.textFields["email"].typeText("user@example.com")
// 点击按钮
app.buttons["Login"].tap()
// 验证结果
XCTAssertTrue(app.staticTexts["Welcome"].exists)
}
运行 UI 测试:
xcodebuild -workspace App.xcworkspace -scheme AppUITests \
-destination "platform=iOS Simulator,id=$UDID" \
test
与 MCP 不同,CLI 工具不维护会话状态。请使用环境变量或配置文件:
# 设置会话变量
export XCODE_WORKSPACE="/path/to/App.xcworkspace"
export XCODE_SCHEME="App"
export SIM_UDID="DD5E339B-468E-43C7-B219-54112C9D3250"
export APP_BUNDLE_ID="com.your.app"
# 在命令中使用
xcodebuild -workspace "$XCODE_WORKSPACE" -scheme "$XCODE_SCHEME" ...
xcrun simctl launch "$SIM_UDID" "$APP_BUNDLE_ID"
# 检查可用的目标设备
xcodebuild -workspace App.xcworkspace -scheme App -showDestinations
# 使用输出中的确切目标设备字符串
# 检查是否已启动
xcrun simctl list devices | grep Booted
# 强制关闭并重新启动
xcrun simctl shutdown $UDID
xcrun simctl boot $UDID
# 检查你指定的派生数据路径
ls -la /tmp/build/Build/Products/Debug-iphonesimulator/
# 或者使用默认的派生数据路径
ls ~/Library/Developer/Xcode/DerivedData/
| 功能 | XcodeBuildMCP | 此技能 |
|---|---|---|
| 构建 | build_sim({...}) | xcodebuild -workspace ... build |
| 列出模拟器 | list_sims() | xcrun simctl list devices |
| 启动应用 | launch_app_sim({...}) | xcrun simctl launch $UDID $BUNDLE |
| 屏幕截图 | screenshot({...}) | xcrun simctl io $UDID screenshot |
| 点击/输入 | tap({x,y}), type_text({...}) | XCUITest 框架 |
| 会话状态 | 内置 | 环境变量 |
每周安装量
150
代码仓库
GitHub 星标数
126
首次出现
2026年1月28日
安全审计
已安装于
codex138
opencode138
gemini-cli131
github-copilot126
cursor115
kimi-cli114
Build and manage iOS/macOS projects using native Xcode CLI tools instead of MCP servers.
Use this skill when:
Preference : Always use direct CLI commands (xcodebuild, xcrun simctl) instead of XcodeBuildMCP tools.
# List schemes in a workspace
xcodebuild -workspace /path/to/App.xcworkspace -list
# List schemes in a project
xcodebuild -project /path/to/App.xcodeproj -list
# Show build settings
xcodebuild -workspace /path/to/App.xcworkspace -scheme AppScheme -showBuildSettings
# List all simulators
xcrun simctl list devices
# List as JSON (better for parsing)
xcrun simctl list devices --json
# List only available simulators
xcrun simctl list devices available
# Get simulator UUID first
UDID=$(xcrun simctl list devices --json | jq -r '.devices | .[].[] | select(.name=="iPhone 16 Pro") | .udid' | head -1)
# Build
xcodebuild \
-workspace /path/to/App.xcworkspace \
-scheme AppScheme \
-destination "platform=iOS Simulator,id=$UDID" \
-configuration Debug \
-derivedDataPath /tmp/build \
build
# Find the built .app
APP_PATH=$(find /tmp/build -name "*.app" -type d | head -1)
# Install on simulator
xcrun simctl install $UDID "$APP_PATH"
# Launch app
xcrun simctl launch $UDID com.your.bundleid
xcrun simctl io $UDID screenshot /tmp/screenshot.png
For comprehensive command documentation, see:
xcodebuild and xcrun simctl command reference# 1. Boot simulator
xcrun simctl boot $UDID 2>/dev/null || true
# 2. Build
xcodebuild -workspace App.xcworkspace -scheme App \
-destination "platform=iOS Simulator,id=$UDID" \
-derivedDataPath /tmp/build build
# 3. Find and install app
APP=$(find /tmp/build -name "*.app" -type d | head -1)
xcrun simctl install $UDID "$APP"
# 4. Launch with console output
xcrun simctl launch --console $UDID com.bundle.id
# Stream app logs (run in background)
/usr/bin/log stream \
--predicate 'processImagePath CONTAINS[cd] "AppName"' \
--style json &
LOG_PID=$!
# ... interact with app ...
# Stop logging
kill $LOG_PID
# Unit tests
xcodebuild -workspace App.xcworkspace -scheme App \
-destination "platform=iOS Simulator,id=$UDID" \
test
# Specific test class
xcodebuild -workspace App.xcworkspace -scheme App \
-destination "platform=iOS Simulator,id=$UDID" \
-only-testing "AppTests/MyTestClass" \
test
For tapping, typing, and UI element queries, use XCUITest (Apple's native UI testing framework).
This is more powerful than MCP-based automation because:
See XCUITEST_GUIDE.md for complete patterns.
Quick example:
// In a UI test file
func testLogin() {
let app = XCUIApplication()
app.launch()
// Type in text field
app.textFields["email"].tap()
app.textFields["email"].typeText("user@example.com")
// Tap button
app.buttons["Login"].tap()
// Verify result
XCTAssertTrue(app.staticTexts["Welcome"].exists)
}
Run UI tests:
xcodebuild -workspace App.xcworkspace -scheme AppUITests \
-destination "platform=iOS Simulator,id=$UDID" \
test
Unlike MCP, CLI tools don't maintain session state. Use environment variables or a config file:
# Set up session variables
export XCODE_WORKSPACE="/path/to/App.xcworkspace"
export XCODE_SCHEME="App"
export SIM_UDID="DD5E339B-468E-43C7-B219-54112C9D3250"
export APP_BUNDLE_ID="com.your.app"
# Use in commands
xcodebuild -workspace "$XCODE_WORKSPACE" -scheme "$XCODE_SCHEME" ...
xcrun simctl launch "$SIM_UDID" "$APP_BUNDLE_ID"
# Check available destinations
xcodebuild -workspace App.xcworkspace -scheme App -showDestinations
# Use exact destination string from output
# Check if already booted
xcrun simctl list devices | grep Booted
# Force shutdown and reboot
xcrun simctl shutdown $UDID
xcrun simctl boot $UDID
# Check derived data path you specified
ls -la /tmp/build/Build/Products/Debug-iphonesimulator/
# Or use default derived data
ls ~/Library/Developer/Xcode/DerivedData/
| Feature | XcodeBuildMCP | This Skill |
|---|---|---|
| Build | build_sim({...}) | xcodebuild -workspace ... build |
| List sims | list_sims() | xcrun simctl list devices |
| Launch app | launch_app_sim({...}) | xcrun simctl launch $UDID $BUNDLE |
| Screenshot |
Weekly Installs
150
Repository
GitHub Stars
126
First Seen
Jan 28, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex138
opencode138
gemini-cli131
github-copilot126
cursor115
kimi-cli114
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
33,600 周安装
screenshot({...})xcrun simctl io $UDID screenshot |
| Tap/Type | tap({x,y}), type_text({...}) | XCUITest framework |
| Session state | Built-in | Environment variables |