Skip to content

Instantly share code, notes, and snippets.

@igor-makarov
Last active October 21, 2025 09:17
Show Gist options
  • Save igor-makarov/e46c7827493016765d6431b6bd1d2394 to your computer and use it in GitHub Desktop.
Save igor-makarov/e46c7827493016765d6431b6bd1d2394 to your computer and use it in GitHub Desktop.
Replace Xcode MCP with CLI (saves about 32k tokens)

Replace Xcode MCP with CLI (saves about 32k tokens)

There are two files:

  • xcodebuild - the script that the agent is expected to run
  • building-with-xcode.md - the instructions given to the agent, i.e. in CLAUDE.md

Using Xcode CLI

When invoked:

  1. Identify the correct Xcode scheme and destination.
  2. The workspace is ./XXX.xcworkspace.
  3. Use Xcode CLI to initiate the build or test: .claude/scripts/xcodebuild <your_params>

Follow these rules:

  • The params to .claude/scripts/xcodebuild are the same as to system's xcodebuild.
  • ❌ Avoid building unrelated targets
  • ❌ NEVER clean the build. Do not ever add clean option. NEVER.
  • .claude/scripts/xcodebuild writes build results to an output file.
  • Always use Read and Search tools to interpret the output file.
  • The output file is large. NEVER read it whole.
  • Use the scheme specified
  • Use the destination specified
#!/bin/bash
set -eo pipefail
mkdir -p ./build/xcodebuild
timestamp=$(date +%Y-%m-%d-%H-%M-%S)
temp_file=$(mktemp ./build/xcodebuild/xcodebuild-output-${timestamp}.XXXXXX)
set +e
xcodebuild "$@" &> "$temp_file"
exit_code=$?
set -e
file_size=$(wc -c < "$temp_file" | tr -d ' ')
echo "Build output saved to: $temp_file"
echo "Build output size: $file_size bytes"
if [ $exit_code -eq 0 ]; then
echo "Build status: SUCCESS"
else
echo "Build status: FAILED (exit code: $exit_code)"
fi
exit $exit_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment