{"slug": "xcode-mcp-vs-xcodebuild-build-and-test-speed-compared", "title": "Xcode MCP vs xcodebuild: build and test speed compared", "summary": "Xcode 27.2 RC's built-in Model Context Protocol server built the RocketSim workspace faster than xcodebuild in every scenario tested, cutting a clean build with a warm compile cache from 51.6 seconds to 42.2 seconds and a no-op build from 20.0 seconds to 13.2 seconds on an Apple M3 Max. The author measured 123 build runs across seven scenarios on the roughly 200-target, 4,649-compile-step project and found the MCP saves a roughly fixed 4-9 seconds per build rather than a percentage, about 10% on a cold clean build and a third of the time on a no-op build. The comparison used Xcode 27.2 RC for both tools, a script calling xcrun mcpbridge over stdio for the MCP, and the repo's own xcodebuild flags with the compile cache enabled for both.", "body_md": "The Xcode MCP is Xcode’s built-in Model Context Protocol server, and its `BuildProject` tool builds your app without you calling `xcodebuild` yourself. Both tools run the same compiler on the same project, so I wanted to know whether the MCP is actually faster, and by how much. I measured it on a real project and the answer is: yes, but not by as much as I hoped for.\n\nI have been running my agents through `xcodebuild` for a long time, with [a hook that filters its output](https://www.avanderlee.com/ai-development/agent-hooks-claude-code-cursor-codex/). Xcode 27’s MCP made me curious whether I should switch for the builds and test runs my agents do all day. After writing about [the MCP’s token costs in the Simulator](https://www.avanderlee.com/ai-development/xcode-mcp-simulator-token-costs/), this is the build and test side of the same question.\n\n## \n\nI used the RocketSim workspace: about 200 targets and 4,649 compile steps in a clean build. That’s a project where build time actually matters. These are the setup details:\n\n- **Machine:** Apple M3 Max with 14 cores and 36 GB of memory, on AC power.\n- **Xcode:** 27.2 RC for both tools. The MCP is served by the headless Xcode service of the selected Xcode, and`xcodebuild` ran with`DEVELOPER_DIR` pointing at the same Xcode.\n- **MCP client:** a script that calls`xcrun mcpbridge` over stdio and uses`BuildProject` , so there is no human or LLM latency in the numbers.\n- **`xcodebuild` command:** the flags of my repo’s own build script, with the compile cache enabled for both tools.\n\n```\nxcodebuild -workspace RocketApps.xcworkspace -scheme RocketSim \\\n  -destination platform=macOS -skipPackageUpdates \\\n  COMPILER_INDEX_STORE_ENABLE=NO build\n```\n\n`COMPILER_INDEX_STORE_ENABLE=NO` tells the compiler not to write index data while it builds. That index powers Xcode’s editor features like jump to definition and code completion, so a command-line build or an agent doesn’t need it, and skipping it saves some work. My repo’s build script sets it, which is why I used it. Xcode has the index store enabled by default, so I also ran `xcodebuild` with it turned on. It made no difference: 50.9 seconds instead of 51.6 seconds on a clean build with a warm compile cache.\n\n- **Noise control:** before every build, the script waited until no`swift-frontend` or`xcodebuild` process ran anywhere on the machine and the CPU was mostly idle. The order of the tools alternated per round.\n\nNot every run was clean. In 20 of 123 build runs, another agent started an `xcodebuild` or test process while I measured. The tables below only use the clean runs, and the numbers including the noisy ones show the same direction with slightly larger gaps.\n\nMy first attempt was wrong. I ran it by hand while my machine was under heavy load, and `xcodebuild` used Xcode 27.3 Beta 2 while the MCP used Xcode 27.2 RC. I threw those numbers away. If you run your own comparison, check which Xcode the MCP actually builds with. The toolchain path shows up in the MCP’s build log.\n\n## \n\nThe MCP was faster in every build scenario I tried. These are median wall times in seconds:\n\n| Scenario | `xcodebuild` | MCP | \n|---|---|---|\n| Clean build, warm compile cache | 51.6 | 42.2 (-8.9 s) | \n| Clean build, cold compile cache | 92.2 | 82.8 (-8.5 s) | \n| No-op build | 20.0 | 13.2 (-4.3 s) | \n| Comment-only edit | 33.6 | 27.5 (-5.1 s) | \n| Body edit in the app target | 33.4 | 24.6 (-6.9 s) | \n| Interface change in a local package | 46.0 | 37.7 (-8.5 s) | \n| Build with a compile error | 31.6 | 21.6 (-4.1 s) | \n\nThe number between brackets is the median of the differences between each pair of runs, so it doesn’t always equal the difference between the two medians.\n\nThe gap is roughly the same size in every row. That means it’s not a percentage: the MCP doesn’t compile faster, it saves a fixed amount of time per build. For a cold clean build, that’s only about 10%. For a no-op build, it’s a third of the time.\n\nI also measured what an agent loop looks like, where the same tool builds again and again after a comment-only edit. With the MCP, those builds took 17.9 seconds. With `xcodebuild`, they took 27.8 seconds. That’s about 10 seconds saved on every build, which adds up quickly when an agent builds dozens of times per task.\n\n## \n\nBoth tools do the same compile work. The clean builds had the same 4,649 compile steps and the same number of compile cache hits, about 1,118 on warm builds and none on cold ones. This means the difference isn’t in the compiling, but in what happens before the compiler starts.\n\nI couldn’t isolate the exact cause, but I found enough to make an educated guess.\n\n### `xcodebuild` starts its build system from scratch\n\nXcode’s build system, [Swift Build](https://github.com/swiftlang/swift-build), runs as a separate service process called `SWBBuildService`. Apple’s [architecture documentation](https://github.com/swiftlang/swift-build/blob/main/SwiftBuild.docc/Architecture/build-system-architecture.md) says:\n\nClients start a SWBBuildService process on demand, and there is a single SWBBuildService process per client process.\n\nI checked this on my Mac with a small package. While `xcodebuild` ran, a new `SWBBuildService` appeared with `xcodebuild` as its parent, and it was gone after the build. Xcode’s own build service and the one of the headless Xcode Service were still running, the latter for more than three days.\n\n### \n\nThe same documentation explains that the build description, which is the plan of every task in your build, can come from an in-memory or an on-disk cache. A service that has been running for days can reuse what it already holds in memory. A fresh one starts empty.\n\nA developer measured this on a project with about 2,100 targets, in a [swift-build issue](https://github.com/swiftlang/swift-build/issues/1111). Computing the target dependency graph took about 7 seconds in Xcode and 29 seconds through `xcodebuild`. Their explanation:\n\n[…] because the service is freshly spawned with no in-memory caches from prior builds.\n\nThat’s an analysis from a contributor, not a statement from Apple, and it was measured on Xcode 26.3. My project is a lot smaller, so I’d expect a smaller saving, which is what I measured. Packages add to this: the same issue lists about 3 to 4 seconds for resolving the package graph on every `xcodebuild` run.\n\n### \n\nApple’s [documentation](https://developer.apple.com/documentation/xcode/giving-agentic-coding-tools-access-to-xcode) tells you to open your project in Xcode before prompting the agent. The [Xcode 27 release notes](https://developer.apple.com/documentation/xcode-release-notes/xcode-27-release-notes) describe a headless mode, which is the one I used:\n\nXcode 27 Beta 5 adds a preview of a new MCP server experience that runs without requiring an open Xcode workspace.\n\nIn both cases a long-running Xcode process serves your build requests. Xcode’s own instructions for agents, which ship inside the app, describe `BuildProject` like this:\n\n`BuildProject` - Build the project in Xcode. Fully compiles and assembles binaries and resources using Xcode’s build system.\n\nIn other words, it’s an Xcode build and not a wrapper around the `xcodebuild` command. It might be that this process keeps your project and build state in memory between requests, so it can skip work that `xcodebuild` has to repeat on every run.\n\n### \n\nApple doesn’t document the MCP’s `BuildProject` as faster than `xcodebuild`, and I didn’t find a statement about it sharing caches with the IDE either. Treat this as my best explanation of a measured gap, not as a confirmed cause. It would also explain why the gap is a fixed amount of seconds instead of a percentage: it’s work that happens once per invocation, no matter how much you compile. I covered the build timing summary that could shed more light on this in [Build performance analysis for speeding up Xcode builds](https://www.avanderlee.com/optimization/analysing-build-performance-xcode/).\n\n## \n\nI ran the same comparison for tests, using `RunSomeTests` and `RunAllTests` against `xcodebuild test`. I measured a single test and the full plan, in a local package and in the app target. Because switching tools has a cost (more on that below), I ran blocks of four runs per tool and only report the steady state.\n\n| Scenario | `xcodebuild` | MCP | Difference | \n|---|---|---|---|\n| Package, 1 test | 10.3 | 4.2 | MCP about 6 s faster | \n| Package, full plan | 10.6 | 6.2 | MCP about 4.5 s faster | \n| App, 1 test | 19.8 | 17.5 | MCP about 2.3 s faster | \n| App, full plan | 22.9 | 23.3 | No difference | \n| App, full plan after a comment edit | 35.3 | 37.7 | `xcodebuild` slightly faster | \n\nThe more interesting result is the last two rows. Once the suite gets bigger, the advantage is gone. The reason is that running the tests is only a small part of the wall time. `xcodebuild` reported 0.6 seconds of actual testing for a single package test, and about 4.6 seconds for my 1,491-test app plan. The rest is planning, a build that has nothing to do, and launching the test host.\n\nIn other words, the test comparison mostly measures the same fixed overhead as the build comparison. If your suite takes a few seconds, you save a large share of it. If your suite takes minutes, you won’t notice.\n\nI also checked whether running the app suite in serial or in parallel made a difference. It didn’t: 23.1 seconds against 22.9 seconds.\n\n## \n\nSpeed is only half of it, because your agent reads the output. This is what came back after a failed build:\n\n| Source | Size | \n|---|---|\n| MCP `BuildProject` response | Under 2 KB | \n| `xcodebuild` raw log | 0.8 to 1.6 MB | \n| `xcodebuild` piped through`xcsift` | 1.2 to 2.4 KB | \n\nThe MCP returns a short, structured list of errors. A raw `xcodebuild` log is hundreds of times larger, and that all ends up in your agent’s context if you don’t filter it. Piping through [xcsift](https://github.com/ldomaradzki/xcsift) brings it back to the same size as the MCP, as I explained in [How to reduce token usage in Claude Code, Codex, and Cursor](https://www.avanderlee.com/ai-development/reduce-token-usage-claude-code-codex-cursor/).\n\nThe test output is similar. For a single app test, the raw `xcodebuild` log was about 554 KB while the MCP replied with under 1 KB. For a full run, the MCP caps the response at 100 test results and writes the full list to a file.\n\n## \n\nThis one surprised me, and it’s the main reason I would pick one tool per worktree. Running `xcodebuild` right after the MCP had built or tested the same workspace was sometimes very slow. Examples:\n\n- The first app test run with `xcodebuild` after a block of MCP runs took 78 seconds (the range was 26.6 to 130 seconds).\n- The first MCP run after `xcodebuild` only took 24 seconds for the same test.\n- A comment-only build with `xcodebuild` after a block of MCP builds took 62 seconds, where the steady-state median was 27.8 seconds.\n\nMy best guess is that the two tools use different build settings, which triggers extra work in the shared DerivedData. I haven’t proven that, and I only have one or two samples per cell. However, if you alternate between both tools in one worktree, you’ll lose the savings I showed above. That’s why the numbers in my tables come from repeated runs with the same tool.\n\n## \n\nAfter seeing the data, I’m moving my local validation scripts in RocketSim to the MCP when it’s available. They fall back to `xcodebuild` otherwise. CI stays on `xcodebuild`, because it re-runs everything on every pull request and doesn’t need the few seconds I would save there.\n\nThis is my current rule of thumb:\n\n- **Use the MCP** for the edit, build, and test loop on your own Mac, especially with small test runs.\n- **Use `xcodebuild`** on CI, when Xcode isn’t available, or when you need result bundles and reproducible logs.\n- **Pick one tool per worktree** to avoid the switching cost.\n\nThere are a few things to know before you start. The MCP is served by Xcode, and it asks for approval for every new folder. If you create worktrees all the time, that gets annoying quickly. You can permit a parent folder once with `allow-folder`, which requires `sudo`:\n\n```\n# Register this command as the MCP server in your agent\nxcrun mcpbridge\n\n# Let headless Xcode serve every workspace below a folder\nsudo xcrun mcp-server allow-folder /path/to/Projects --always\n```\n\nYou can check the result with `xcrun mcp-server status`. Apple documents the setup in [Giving external agentic coding tools access to Xcode](https://developer.apple.com/documentation/xcode/giving-agentic-coding-tools-access-to-xcode).\n\nThe second thing is shared state. The active scheme and test plan live in the MCP server, so every agent that uses it shares them. I switched schemes several times during this research. With multiple agents in different worktrees, one agent switching the scheme could change what another agent builds. I haven’t tested this with agents running at the same time, so treat it as a risk and don’t switch schemes mid-session.\n\nThe last thing is reliability. In my first pass, 8 MCP test runs returned an empty response after 0.0 seconds instead of running tests. I discarded them and reran the same setup successfully, but I never found the cause. It’s one more reason to keep `xcodebuild` as a fallback.\n\n## \n\nI tested one project on one Mac with one Xcode version. Your absolute numbers will differ, and the pattern of a fixed gap is the finding I would verify first. Some cells only have 3 to 8 pairs, so read the results as direction and rough size, not as statistics. In other words, I did my best to measure this as closely as possible, but your project is the only benchmark that really counts.\n\n## \n\nThe Xcode MCP builds and tests faster than `xcodebuild` by a few seconds per run, replies with a much smaller output, and wins most for small, repeated runs like an agent loop. On large test suites the advantage disappears, and switching between both tools in the same worktree can cost you more than you save.\n\nI’d use the MCP on your own machine and `xcodebuild` on CI. If you want to learn how to build validation loops that keep your agent’s context small, the [AI Fundamentals course](https://aifundamentals.dev?utm_source=swiftlee&utm_medium=article&utm_campaign=xcode-mcp-vs-xcodebuild) covers it step by step.\n\nFeel free to contact me or [tweet me on Twitter](https://twitter.com/twannl) if you have any additional tips or feedback. Do you let your agents build with the Xcode MCP yet, or do you stick with `xcodebuild`?\n\nThanks!", "url": "https://wpnews.pro/news/xcode-mcp-vs-xcodebuild-build-and-test-speed-compared", "canonical_source": "https://www.avanderlee.com/ai-development/xcode-mcp-vs-xcodebuild/", "published_at": "2026-11-23 14:54:13+00:00", "updated_at": "2026-11-23 15:14:14.043725+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "agent-protocols", "ai-tools"], "entities": ["Xcode", "Model Context Protocol", "xcodebuild", "RocketSim", "Apple", "xcrun mcpbridge", "Xcode 27.2 RC"], "also_reported_by": [], "takeaway": "Xcode 27.2 RC's MCP BuildProject tool saved a roughly fixed 4-9 seconds per build versus xcodebuild on a 4,649-compile-step project — 51.6s to 42.2s on a warm-cache clean build and 20.0s to 13.2s on a no-op build.", "recommendation": {"advice": "Route agent builds through Xcode's MCP BuildProject tool instead of xcodebuild to save a fixed 4-9 seconds per build, and verify the MCP's toolchain path in its build log before trusting comparisons.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/xcode-mcp-vs-xcodebuild-build-and-test-speed-compared", "markdown": "https://wpnews.pro/news/xcode-mcp-vs-xcodebuild-build-and-test-speed-compared.md", "text": "https://wpnews.pro/news/xcode-mcp-vs-xcodebuild-build-and-test-speed-compared.txt", "jsonld": "https://wpnews.pro/news/xcode-mcp-vs-xcodebuild-build-and-test-speed-compared.jsonld"}}