Help us improve
Share bugs, ideas, or general feedback.
From apple-docs
Build Swift packages and Xcode projects, run tests, and interpret results.
npx claudepluginhub briannadoubt/claude-marketplace --plugin apple-docsHow this skill is triggered — by the user, by Claude, or both
Slash command
/apple-docs:build-and-testThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build Swift packages and Xcode projects, run tests, and interpret results.
Guides Xcode build workflows for iOS projects using execute_xcode_command tool. Covers builds, tests, cleans, schemes, xcodebuild output interpretation, and error troubleshooting.
Builds, runs, and tests pure SwiftPM-based macOS packages and executables. Activates when Package.swift is the primary entrypoint or SwiftPM workflows are the fastest path to diagnosis.
Builds and runs iOS/macOS apps with xcodebuild and xcrun simctl. Manages simulators, compiles Swift, runs UI/unit tests, captures logs/screenshots, automates interactions.
Share bugs, ideas, or general feedback.
Build Swift packages and Xcode projects, run tests, and interpret results.
# Build (debug)
swift build
# Build (release)
swift build -c release
# Build specific target
swift build --target MyTarget
# Build with verbose output
swift build -v
# Run all tests
swift test
# Run specific test class
swift test --filter MyTests
# Run specific test method
swift test --filter MyTests/testSomething
# Run with verbose output (see each test)
swift test -v
# Run tests in parallel
swift test --parallel
# Enable coverage
swift test --enable-code-coverage
# Find coverage data
COVERAGE_PATH=$(swift test --enable-code-coverage 2>&1 | grep "llvm-cov" | sed 's/.*export //' | awk '{print $1}')
# View coverage report (requires successful test run first)
xcrun llvm-cov report \
.build/debug/YourPackagePackageTests.xctest/Contents/MacOS/YourPackagePackageTests \
-instr-profile=.build/debug/codecov/default.profdata
# List available schemes
xcodebuild -list
# Build a scheme
xcodebuild -scheme MyScheme -destination 'platform=iOS Simulator,name=iPhone 16' build
# Run tests
xcodebuild -scheme MyScheme -destination 'platform=iOS Simulator,name=iPhone 16' test
# Build for specific SDK
xcodebuild -scheme MyScheme -sdk iphonesimulator build
# Clean build
xcodebuild -scheme MyScheme clean build
# Extract just errors from build output
swift build 2>&1 | grep -E "error:|warning:"
# Get context around errors
swift build 2>&1 | grep -B2 -A2 "error:"
| Pattern | Meaning |
|---|---|
cannot find 'X' in scope | Missing import or typo |
type 'X' has no member 'Y' | Wrong method/property name |
cannot convert value | Type mismatch |
missing argument | Function call missing required param |
ambiguous use of | Multiple matching overloads |
# Run tests and capture output
swift test 2>&1 | tee test-output.txt
# Find failures
grep -E "failed|FAIL" test-output.txt
# Get failure details
grep -B5 -A10 "failed" test-output.txt
Test Case '-[ModuleTests.MyTests testExample]' started.
/path/to/file.swift:42: error: -[ModuleTests.MyTests testExample] : XCTAssertEqual failed: ("1") is not equal to ("2")
Test Case '-[ModuleTests.MyTests testExample]' failed (0.001 seconds).
# Resolve dependencies first
swift package resolve
swift build
# Swift Package
rm -rf .build && swift build
# Xcode
xcodebuild clean && xcodebuild build -scheme MyScheme
swift package update
# Run default executable
swift run
# Run specific product
swift run MyExecutable
# Run with arguments
swift run MyExecutable --arg1 value1
# Run release build
swift run -c release MyExecutable
swift build before swift test to get cleaner error output-v (verbose) when you need to see what's happening--filter to speed up iterationPackage.swift for available targets and productsFor structured output or advanced features:
swift_build - Returns parsed errors/warnings as JSONswift_test - Returns test results with pass/fail countsswift_run - Captures stdout/stderr separately