From swift-engineer
Builds the current Xcode project (fixing errors automatically), then runs the app on macOS or iOS Simulator. Optional [scheme] argument.
How this command is triggered — by the user, by Claude, or both
Slash command
/swift-engineer:build-and-run [scheme]sonnetThis command is limited to the following tools:
The summary Claude sees in its command listing — used to decide when to auto-load this command
Build and run the current Xcode project. **Important:** Run all `xcodebuild` commands as background tasks. Builds can take significant time (30s–5m+ depending on project size). Use Bash with `run_in_background: true` parameter to avoid blocking. Poll build completion and capture output for error analysis. ## Workflow ### Step 1: Find the Project Look for `.xcworkspace` (preferred) or `.xcodeproj` in current directory. If multiple exist, ask the user which to use. ### Step 2: Find the Scheme Get available schemes with: or If multiple schemes exist, ask the user which to build. If...
Build and run the current Xcode project.
Important: Run all xcodebuild commands as background tasks. Builds can take significant time (30s–5m+ depending on project size). Use Bash with run_in_background: true parameter to avoid blocking. Poll build completion and capture output for error analysis.
Look for .xcworkspace (preferred) or .xcodeproj in current directory. If multiple exist, ask the user which to use.
Get available schemes with:
xcodebuild -workspace <workspace> -list -quiet
or
xcodebuild -project <project> -list -quiet
If multiple schemes exist, ask the user which to build. If scheme is provided as $1, use that.
Run as background task to avoid blocking.
For macOS projects, build for native architecture:
ARCH=$(uname -m)
xcodebuild -project <project> -scheme <scheme> -destination "platform=macOS,arch=$ARCH" -quiet build
For iOS projects, determine available simulator and build:
SIMULATOR=$(xcrun simctl list devices available -j | python3 -c "import sys,json; devs=[d for r in json.load(sys.stdin)['devices'].values() for d in r if d['isAvailable']]; iphones=[d for d in devs if 'iPhone' in d['name']]; print(iphones[-1]['name'] if iphones else '')")
xcodebuild -project <project> -scheme <scheme> -destination "platform=iOS Simulator,name=$SIMULATOR" -quiet build
When build completes (exit code 0 = success, non-zero = failure), proceed to Step 4 if errors, or Step 5 if successful.
If build fails, read error messages and fix each issue:
Prioritize errors over warnings.
For macOS:
# Get native architecture and build output directory
ARCH=$(uname -m)
BUILT_PRODUCTS_DIR=$(xcodebuild -project <project> -scheme <scheme> -destination "platform=macOS,arch=$ARCH" -quiet -showBuildSettings | grep ' BUILT_PRODUCTS_DIR =' | awk '{print $3}')
# Kill previous instance and run
if [ -f .build.pid ]; then
OLD_PID=$(cat .build.pid)
kill -0 "$OLD_PID" 2>/dev/null && kill "$OLD_PID" 2>/dev/null
fi
open "$BUILT_PRODUCTS_DIR/<app-name>.app"
sleep 1
pgrep -f "$BUILT_PRODUCTS_DIR/<app-name>" > .build.pid
For iOS:
# Get bundle identifier from Info.plist or build settings
BUNDLE_ID=$(xcodebuild -project <project> -scheme <scheme> -quiet -showBuildSettings | grep ' PRODUCT_BUNDLE_IDENTIFIER =' | awk '{print $3}')
# Boot simulator and launch
xcrun simctl boot "$SIMULATOR" 2>/dev/null
xcrun simctl launch --terminate-running-process booted "$BUNDLE_ID"
Report success or errors to the user.
If build issues persist or changes aren't being picked up, clean DerivedData and rebuild:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Then rebuild from Step 3. This removes all cached build artifacts and forces a fresh build. Use sparingly—only when a rebuild doesn't pick up code changes or when encountering mysterious build failures.
npx claudepluginhub sjungling/sjungling-claude-plugins --plugin swift-engineer/ios-buildBuilds iOS projects with Xcode — runs xcodebuild, resolves build errors automatically, and exports .ipa archives. Also accepts release and test arguments.
/fix-buildDiagnoses and fixes Xcode build failures by launching a build-fixer agent that checks zombie processes, cleans Derived Data, and verifies simulator state.
/xcode-testBuilds, installs, tests, and captures screenshots of iOS apps on a simulator using XcodeBuildMCP, surfacing crashes and UI issues.
/test-xcodeBuilds, installs, and tests iOS apps on the simulator using XcodeBuildMCP. Captures screenshots and console logs, supports human verification for external flows.
/macos-runtime-debugCreates or updates a local build-and-run script for macOS Xcode/SwiftPM projects, with optional debug, logs, telemetry, and verify modes.