Get the FREE Ultimate OpenClaw Setup Guide →

build-and-test

npx machina-cli add skill xvirobotics/metaskill/build-and-test --openclaw
Files (1)
SKILL.md
2.7 KB

You are a build and test automation specialist. Your job is to build the Xcode project and run its test suite, then report results clearly.

Auto-Detected Context

Current branch: !git branch --show-current Recent changes: !git diff --stat HEAD~3 2>/dev/null || echo "fewer than 3 commits"

Instructions

Step 1: Locate the Xcode Project

Find the .xcodeproj or .xcworkspace file:

find . -maxdepth 3 -name "*.xcworkspace" -not -path "*/Pods/*" | head -1
find . -maxdepth 3 -name "*.xcodeproj" | head -1

If a .xcworkspace exists, use it. Otherwise use the .xcodeproj.

Step 2: Identify Schemes and Destinations

List available schemes:

xcodebuild -list -workspace <workspace> 2>/dev/null || xcodebuild -list -project <project>

List available simulators to pick an appropriate test destination:

xcrun simctl list devices available --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for runtime, devices in data.get('devices', {}).items():
    if 'iOS' in runtime:
        for d in devices:
            if d.get('isAvailable'):
                print(f\"{d['name']} ({runtime.split('.')[-1]})  UDID: {d['udid']}\")
" 2>/dev/null | head -10

Select the latest iPhone simulator (prefer iPhone 15 Pro or iPhone 16 Pro).

Step 3: Build the Project

xcodebuild build \
  -workspace <workspace-or-project> \
  -scheme <scheme> \
  -destination 'platform=iOS Simulator,name=<simulator-name>' \
  -quiet \
  2>&1

If the build fails, capture the full error output and report it. Do not proceed to testing.

Step 4: Run Tests

xcodebuild test \
  -workspace <workspace-or-project> \
  -scheme <scheme> \
  -destination 'platform=iOS Simulator,name=<simulator-name>' \
  -resultBundlePath ./TestResults.xcresult \
  2>&1

Step 5: Parse and Report Results

Parse the xcodebuild output for:

  • Total tests run, passed, failed, skipped
  • Names of failing tests with error messages
  • Build warnings

Report in this format:

## Build & Test Results

### Build: PASS / FAIL
[Build errors if any]

### Tests: X passed, Y failed, Z skipped
[Total execution time]

### Failures
- TestTarget/TestClass/testMethodName: [error message]
  [relevant code context]

### Warnings
- [any build warnings worth noting]

If all tests pass, confirm with a clean summary. If tests fail, provide the failure details with enough context to understand and fix each failure.

Source

git clone https://github.com/xvirobotics/metaskill/blob/main/examples/ios-app/.claude/skills/build-and-test/SKILL.mdView on GitHub

Overview

Automates building an Xcode project and executing its full test suite. It verifies compilation, runs unit tests, and surfaces detailed failures and warnings so issues can be fixed quickly. The skill reports a clear pass/fail status with error output.

How This Skill Works

Locates the Xcode artifact (.xcworkspace or .xcodeproj), discovers available schemes and destinations, builds with xcodebuild, then runs the test suite. Results are parsed to present totals (passed/failed/skipped), failing test details with messages, and warnings for actionable insights.

When to Use It

  • Before creating a PR to ensure the code compiles and tests pass
  • In CI to validate changes on a clean build with a proper simulator
  • When adding or refactoring code that could affect unit tests
  • To investigate build or test failures with detailed error output
  • During nightly or release pipelines to ensure stability

Quick Start

  1. Step 1: Locate the Xcode project or workspace using the provided find commands and choose the .xcworkspace if present, otherwise the .xcodeproj
  2. Step 2: Identify the scheme and destination by listing schemes and selecting the latest iOS Simulator (e.g., iPhone 15 Pro/16 Pro)
  3. Step 3: Build the project with xcodebuild, then run tests and parse the results for a structured report

Best Practices

  • Prefer using the latest iOS Simulator (e.g., iPhone 15 Pro/16 Pro) for tests
  • Always capture full build errors and don’t proceed to testing if build fails
  • Explicitly specify the workspace/project and scheme to avoid ambiguity
  • Keep TestResults and logs accessible for troubleshooting
  • Regularly prune stale simulators and clean builds to reduce flakiness

Example Use Cases

  • CI pipeline that builds the app and runs all tests on every commit
  • Local verification after introducing a new feature
  • Pre-merge check to catch breaking changes
  • Nightly build validating the full test suite
  • New dependency updates verified with full test run

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers