# Use Xcode MCP Instead of xcodebuild to Save Disk Space and Time in Agentic iOS Development

> 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: 2026-07-11 14:28:46+00:00

**TL;DR** - When setting up an AI agent for iOS development, the default approach is to have the agent run headless `xcodebuild`

commands. To save disk space and time, you might point the agent at your active Xcode `DerivedData`

folder. **I found that this doesn't work.** While they write to the same directory, `xcodebuild`

and 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`

). This allows your agent to use Xcode.app's internal build engine, safely sharing a single `DerivedData`

folder, drastically reducing disk usage, and preserving fast incremental builds when switching between xcode and agent (terminal).

When doing AI driven iOS development, one of the most common approach is to have our agent operates via the command line (`xcodebuild`

), while you might be doing some debugging / UI verification in the GUI (`Xcode.app`

).

Because 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.

It is tempting to pass `-derivedDataPath`

to your agent's `xcodebuild`

commands, pointing it exactly at your live Xcode workspace's DerivedData. The goal is to have the agent "pick up where you left off."

I found that sharing the directory destroys the incremental state for both tools instead.

You can run a targeted test on any active project to see the time penalty yourself.

Set your project variables:

Bash

```
cd /path/to/repo/iOS
WORKSPACE=GoodNotes.xcworkspace
SCHEME=GoodNotes

# A booted/available simulator UDID - adjust as needed:
SIM_UDID=$(xcrun simctl list devices available | grep -oE '[0-9A-F-]{36}' | head -1)

# Your Xcode's DerivedData folder location
DD=/path/DerivedData
```

Enable build durations in Xcode to accurately read the GUI's timings:

Bash

```
defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES
# Restart Xcode after running this
```

**Step 1 — Build in Xcode (⌘B), then build again.**

The second build is a fast, no-op incremental build.

**Step 2 — Run xcodebuild against the same DerivedData.**

Use the exact same scheme, destination, and DerivedData path with no source changes:

Bash

```
xcodebuild build \
  -workspace "$WORKSPACE" \
  -scheme "$SCHEME" \
  -destination "platform=iOS Simulator,id=$SIM_UDID" \
  -derivedDataPath "$DD" \
  -skipMacroValidation \
  -skipPackagePluginValidation \
  -skipPackageUpdates
```

Despite 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.

**Step 3 — Build in Xcode again (⌘B).**

The build becomes slow again. The CLI run overwrote the shared object files and `.swiftmodule`

s on disk. Because the intermediate files were modified by a different build driver, Xcode is forced to rebuild a massive portion of the graph.

Here is the exact performance penalty measured on the app I'm working on.

Build |
Driver |
Time (% of Clean Build) |
|---|---|---|
| Incremental, no changes | Xcode.app |
22.7 s (~2.3%) |
| Same tree, immediately after | `xcodebuild` |
863.0 s (~86.3%) |
| Incremental, immediately after CLI | Xcode.app |
300.8 s (~30.1%) |

By forcing `xcodebuild`

into 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).

Using xcode MCP, I was able to save SSD space by using a single DerivedData directory, and maintain fast incremental build times.

To accomplish this, use the Xcode MCP bridge (`xcrun mcpbridge`

), introduced in Xcode 26.

When your agent uses `xcrun mcpbridge`

to trigger a build:

`BuildProject`

tool 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`

command, you can simply ask the agent to use xcode MCP and it knows what to do.
