{"slug": "use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios", "title": "Use Xcode MCP Instead of xcodebuild to Save Disk Space and Time in Agentic iOS Development", "summary": "A developer found that sharing a single DerivedData folder between Xcode.app and xcodebuild for AI-driven iOS development destroys incremental build state, causing full rebuilds and massive slowdowns. Using the Xcode MCP bridge (xcrun mcpbridge) instead allows the agent to use Xcode's internal build engine, preserving fast incremental builds and saving disk space.", "body_md": "**TL;DR** - When setting up an AI agent for iOS development, the default approach is to have the agent run headless `xcodebuild`\n\ncommands. To save disk space and time, you might point the agent at your active Xcode `DerivedData`\n\nfolder. **I found that this doesn't work.** While they write to the same directory, `xcodebuild`\n\nand Xcode.app do not actually share their incremental build state. Instead, they overwrite each other's intermediate files, forcing rebuilds. To fix this, drive headless builds using the Xcode MCP bridge (`xcrun mcpbridge`\n\n). This allows your agent to use Xcode.app's internal build engine, safely sharing a single `DerivedData`\n\nfolder, drastically reducing disk usage, and preserving fast incremental builds when switching between xcode and agent (terminal).\n\nWhen doing AI driven iOS development, one of the most common approach is to have our agent operates via the command line (`xcodebuild`\n\n), while you might be doing some debugging / UI verification in the GUI (`Xcode.app`\n\n).\n\nBecause DerivedData folders frequently exceed 10GB–20GB for modern apps, maintaining separate build directories for the human and the agent wastes massive amounts of SSD space. It also wastes time, as the agent cannot benefit from the compilation work you just completed in Xcode.\n\nIt is tempting to pass `-derivedDataPath`\n\nto your agent's `xcodebuild`\n\ncommands, pointing it exactly at your live Xcode workspace's DerivedData. The goal is to have the agent \"pick up where you left off.\"\n\nI found that sharing the directory destroys the incremental state for both tools instead.\n\nYou can run a targeted test on any active project to see the time penalty yourself.\n\nSet your project variables:\n\nBash\n\n```\ncd /path/to/repo/iOS\nWORKSPACE=GoodNotes.xcworkspace\nSCHEME=GoodNotes\n\n# A booted/available simulator UDID - adjust as needed:\nSIM_UDID=$(xcrun simctl list devices available | grep -oE '[0-9A-F-]{36}' | head -1)\n\n# Your Xcode's DerivedData folder location\nDD=/path/DerivedData\n```\n\nEnable build durations in Xcode to accurately read the GUI's timings:\n\nBash\n\n```\ndefaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES\n# Restart Xcode after running this\n```\n\n**Step 1 — Build in Xcode (⌘B), then build again.**\n\nThe second build is a fast, no-op incremental build.\n\n**Step 2 — Run xcodebuild against the same DerivedData.**\n\nUse the exact same scheme, destination, and DerivedData path with no source changes:\n\nBash\n\n```\nxcodebuild build \\\n  -workspace \"$WORKSPACE\" \\\n  -scheme \"$SCHEME\" \\\n  -destination \"platform=iOS Simulator,id=$SIM_UDID\" \\\n  -derivedDataPath \"$DD\" \\\n  -skipMacroValidation \\\n  -skipPackagePluginValidation \\\n  -skipPackageUpdates\n```\n\nDespite no code changing, the CLI executes a **full rebuild**. It recompiles, relinks, and re-signs the application instead of acting incrementally relative to Xcode's previous build.\n\n**Step 3 — Build in Xcode again (⌘B).**\n\nThe build becomes slow again. The CLI run overwrote the shared object files and `.swiftmodule`\n\ns on disk. Because the intermediate files were modified by a different build driver, Xcode is forced to rebuild a massive portion of the graph.\n\nHere is the exact performance penalty measured on the app I'm working on.\n\nBuild |\nDriver |\nTime (% of Clean Build) |\n|---|---|---|\n| Incremental, no changes | Xcode.app |\n22.7 s (~2.3%) |\n| Same tree, immediately after | `xcodebuild` |\n863.0 s (~86.3%) |\n| Incremental, immediately after CLI | Xcode.app |\n300.8 s (~30.1%) |\n\nBy forcing `xcodebuild`\n\ninto Xcode's DerivedData, the CLI build ran slower than a clean build, and it dragged Xcode's subsequent incremental build from 22.7 seconds up to 300.8 seconds (a ~13× slowdown).\n\nUsing xcode MCP, I was able to save SSD space by using a single DerivedData directory, and maintain fast incremental build times.\n\nTo accomplish this, use the Xcode MCP bridge (`xcrun mcpbridge`\n\n), introduced in Xcode 26.\n\nWhen your agent uses `xcrun mcpbridge`\n\nto trigger a build:\n\n`BuildProject`\n\ntool calls Xcode.app's internal build system.Look at [this page](https://developer.apple.com/documentation/xcode/giving-external-agents-access-to-xcode) from Apple to see how to enable this for Claude / Codex. In my experience, after running `mcp add`\n\ncommand, you can simply ask the agent to use xcode MCP and it knows what to do.", "url": "https://wpnews.pro/news/use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios", "canonical_source": "https://dev.to/isekai_kara_no_dev/-use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios-development-2m4j", "published_at": "2026-07-11 14:28:46+00:00", "updated_at": "2026-07-11 14:45:01.933214+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "ai-agents"], "entities": ["Xcode", "xcodebuild", "xcrun mcpbridge", "DerivedData", "GoodNotes"], "alternates": {"html": "https://wpnews.pro/news/use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios", "markdown": "https://wpnews.pro/news/use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios.md", "text": "https://wpnews.pro/news/use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios.txt", "jsonld": "https://wpnews.pro/news/use-xcode-mcp-instead-of-xcodebuild-to-save-disk-space-and-time-in-agentic-ios.jsonld"}}