Xcode Build MCP
Build, test, run, and manage Xcode projects and Swift packages via the XcodeBuildMCP server.
When to Use
- User wants to build an iOS/macOS/watchOS/tvOS/visionOS app
- User wants to run tests on simulator or device
- User wants to launch an app on simulator or device
- User mentions "xcodebuild", "swift build", "swift test"
- User wants to scaffold a new iOS/macOS project
- User wants to interact with iOS simulator (tap, type, screenshot)
- User wants to capture logs from simulator or device
- User wants to discover Xcode projects in a directory
Quick Reference
All tools are called via mcporter using the XcodeBuildMCP server:
bunx mcporter call --stdio "xcodebuildmcp" <tool_name> [args...]Assumes mcporter and xcodebuildmcp are installed globally; bunx runs the installed binaries and does not fetch them.
Session Defaults (IMPORTANT - Set First!)
Before using most build/test tools, you MUST set session defaults:
bunx mcporter call --stdio "xcodebuildmcp" session-set-defaults \
projectPath="/path/to/Project.xcodeproj" \
scheme="MyApp" \
simulatorName="iPhone 16"Or for a workspace:
bunx mcporter call --stdio "xcodebuildmcp" session-set-defaults \
workspacePath="/path/to/Project.xcworkspace" \
scheme="MyApp" \
simulatorId="DEVICE_UDID"Check current defaults:
bunx mcporter call --stdio "xcodebuildmcp" session-show-defaultsClear defaults:
bunx mcporter call --stdio "xcodebuildmcp" session-clear-defaults all=trueDiscovery Tools
Find Xcode Projects
bunx mcporter call --stdio "xcodebuildmcp" discover_projs workspaceRoot="$(pwd)"List Schemes
bunx mcporter call --stdio "xcodebuildmcp" list_schemesDoctor (Check Environment)
bunx mcporter call --stdio "xcodebuildmcp" doctorSimulator Tools
List Simulators
bunx mcporter call --stdio "xcodebuildmcp" list_simsBoot Simulator
bunx mcporter call --stdio "xcodebuildmcp" boot_simOpen Simulator App
bunx mcporter call --stdio "xcodebuildmcp" open_simBuild for Simulator
bunx mcporter call --stdio "xcodebuildmcp" build_simBuild and Run on Simulator
bunx mcporter call --stdio "xcodebuildmcp" build_run_simRun Tests on Simulator
bunx mcporter call --stdio "xcodebuildmcp" test_simGet Built App Path (Simulator)
bunx mcporter call --stdio "xcodebuildmcp" get_sim_app_path platform="iOS Simulator"Install App on Simulator
bunx mcporter call --stdio "xcodebuildmcp" install_app_sim appPath="/path/to/App.app"Launch App on Simulator
bunx mcporter call --stdio "xcodebuildmcp" launch_app_sim bundleId="com.example.MyApp"Stop App on Simulator
bunx mcporter call --stdio "xcodebuildmcp" stop_app_sim bundleId="com.example.MyApp"Simulator UI Automation
Take Screenshot
bunx mcporter call --stdio "xcodebuildmcp" screenshotDescribe UI (Get View Hierarchy)
Gets precise frame coordinates for all visible elements - USE THIS before any UI interactions:
bunx mcporter call --stdio "xcodebuildmcp" describe_uiTap
# Tap by coordinates (use describe_ui first to get coordinates)
bunx mcporter call --stdio "xcodebuildmcp" tap x=100 y=200
# Tap by accessibility ID
bunx mcporter call --stdio "xcodebuildmcp" tap id="myButton"
# Tap by label
bunx mcporter call --stdio "xcodebuildmcp" tap label="Submit"Long Press
bunx mcporter call --stdio "xcodebuildmcp" long_press x=100 y=200 duration=1000Swipe
bunx mcporter call --stdio "xcodebuildmcp" swipe x1=100 y1=400 x2=100 y2=100Gesture Presets
bunx mcporter call --stdio "xcodebuildmcp" gesture preset="scroll-down"
# Presets: scroll-up, scroll-down, scroll-left, scroll-right,
# swipe-from-left-edge, swipe-from-right-edge,
# swipe-from-top-edge, swipe-from-bottom-edgeType Text
bunx mcporter call --stdio "xcodebuildmcp" type_text text="Hello World"Press Button
bunx mcporter call --stdio "xcodebuildmcp" button buttonType="home"
# Types: apple-pay, home, lock, side-button, siriKey Press
bunx mcporter call --stdio "xcodebuildmcp" key_press keyCode=40 # Return key
# Common: 40=Return, 42=Backspace, 43=Tab, 44=SpaceSimulator Settings
Set Appearance (Dark/Light Mode)
bunx mcporter call --stdio "xcodebuildmcp" set_sim_appearance mode="dark"Set Location
bunx mcporter call --stdio "xcodebuildmcp" set_sim_location latitude=37.7749 longitude=-122.4194Reset Location
bunx mcporter call --stdio "xcodebuildmcp" reset_sim_locationSet Status Bar Network
bunx mcporter call --stdio "xcodebuildmcp" sim_statusbar dataNetwork="5g"
# Options: clear, hide, wifi, 3g, 4g, lte, lte-a, lte+, 5g, 5g+, 5g-uwb, 5g-ucErase Simulator
bunx mcporter call --stdio "xcodebuildmcp" erase_sims shutdownFirst=trueSimulator Log Capture
Start Log Capture
bunx mcporter call --stdio "xcodebuildmcp" start_sim_log_cap bundleId="com.example.MyApp"
# Returns a logSessionIdStop Log Capture
bunx mcporter call --stdio "xcodebuildmcp" stop_sim_log_cap logSessionId="SESSION_ID"Video Recording
Start Recording
bunx mcporter call --stdio "xcodebuildmcp" record_sim_video start=trueStop Recording
bunx mcporter call --stdio "xcodebuildmcp" record_sim_video stop=true outputFile="/path/to/output.mp4"Physical Device Tools
List Connected Devices
bunx mcporter call --stdio "xcodebuildmcp" list_devicesBuild for Device
bunx mcporter call --stdio "xcodebuildmcp" build_deviceTest on Device
bunx mcporter call --stdio "xcodebuildmcp" test_deviceInstall App on Device
bunx mcporter call --stdio "xcodebuildmcp" install_app_device appPath="/path/to/App.app"Launch App on Device
bunx mcporter call --stdio "xcodebuildmcp" launch_app_device bundleId="com.example.MyApp"Stop App on Device
bunx mcporter call --stdio "xcodebuildmcp" stop_app_device processId=12345Device Log Capture
# Start
bunx mcporter call --stdio "xcodebuildmcp" start_device_log_cap bundleId="com.example.MyApp"
# Stop
bunx mcporter call --stdio "xcodebuildmcp" stop_device_log_cap logSessionId="SESSION_ID"macOS Tools
Build macOS App
bunx mcporter call --stdio "xcodebuildmcp" build_macosBuild and Run macOS App
bunx mcporter call --stdio "xcodebuildmcp" build_run_macosTest macOS App
bunx mcporter call --stdio "xcodebuildmcp" test_macosGet macOS App Path
bunx mcporter call --stdio "xcodebuildmcp" get_mac_app_pathLaunch macOS App
bunx mcporter call --stdio "xcodebuildmcp" launch_mac_app appPath="/path/to/App.app"Stop macOS App
bunx mcporter call --stdio "xcodebuildmcp" stop_mac_app appName="MyApp"Swift Package Tools
Build Package
bunx mcporter call --stdio "xcodebuildmcp" swift_package_build packagePath="$(pwd)"Test Package
bunx mcporter call --stdio "xcodebuildmcp" swift_package_test packagePath="$(pwd)"Run Package Executable
bunx mcporter call --stdio "xcodebuildmcp" swift_package_run packagePath="$(pwd)"Clean Package
bunx mcporter call --stdio "xcodebuildmcp" swift_package_clean packagePath="$(pwd)"List Running Packages
bunx mcporter call --stdio "xcodebuildmcp" swift_package_listStop Package Process
bunx mcporter call --stdio "xcodebuildmcp" swift_package_stop pid=12345Project Scaffolding
Create New iOS Project
bunx mcporter call --stdio "xcodebuildmcp" scaffold_ios_project \
projectName="MyApp" \
outputPath="$(pwd)" \
bundleIdentifier="com.example.myapp"Create New macOS Project
bunx mcporter call --stdio "xcodebuildmcp" scaffold_macos_project \
projectName="MyMacApp" \
outputPath="$(pwd)" \
bundleIdentifier="com.example.mymacapp"Utility Tools
Clean Build
bunx mcporter call --stdio "xcodebuildmcp" cleanShow Build Settings
bunx mcporter call --stdio "xcodebuildmcp" show_build_settingsGet Bundle ID from App
bunx mcporter call --stdio "xcodebuildmcp" get_app_bundle_id appPath="/path/to/App.app"Typical Workflows
Build and Test iOS App on Simulator
# 1. Discover projects
bunx mcporter call --stdio "xcodebuildmcp" discover_projs workspaceRoot="$(pwd)"
# 2. List simulators
bunx mcporter call --stdio "xcodebuildmcp" list_sims
# 3. Set session defaults
bunx mcporter call --stdio "xcodebuildmcp" session-set-defaults \
projectPath="$(pwd)/MyApp.xcodeproj" \
scheme="MyApp" \
simulatorName="iPhone 16"
# 4. Build and run
bunx mcporter call --stdio "xcodebuildmcp" build_run_sim
# 5. Run tests
bunx mcporter call --stdio "xcodebuildmcp" test_simUI Testing Flow
# 1. Build and launch app
bunx mcporter call --stdio "xcodebuildmcp" build_run_sim
# 2. Get UI hierarchy (ALWAYS do this before interacting)
bunx mcporter call --stdio "xcodebuildmcp" describe_ui
# 3. Take screenshot for visual reference
bunx mcporter call --stdio "xcodebuildmcp" screenshot
# 4. Interact with elements using coordinates from describe_ui
bunx mcporter call --stdio "xcodebuildmcp" tap x=187 y=423
# 5. Type text
bunx mcporter call --stdio "xcodebuildmcp" type_text text="test@example.com"Error Handling
| Error | Cause | Solution |
|---|---|---|
| No project/workspace set | Session defaults not configured | Run session-set-defaults first |
| Simulator not found | Invalid simulator name | Run list_sims to get valid names |
| Build failed | Code errors or config issues | Check build output, run doctor |
| App not installed | Build didn't complete | Run build_sim before launch_app_sim |
Tips
- Always set session defaults first - Most tools require project/scheme/simulator to be set
- Use describe_ui before UI interactions - Never guess coordinates from screenshots
- Check doctor for environment issues - Run
doctorif tools aren't working - Use preferXcodebuild=true if incremental builds fail - Falls back to standard xcodebuild