askill
using-xcode-cli

using-xcode-cliSafety 90Repository

Builds and manages iOS/macOS apps using xcodebuild and xcrun simctl CLI tools. Use when working with Xcode projects, running apps in simulators, managing simulator instances, taking screenshots, capturing logs, running tests, or automating builds.

0 stars
1.2k downloads
Updated 2/5/2026

Package Files

Loading files...
SKILL.md

Using Xcode CLI

Overview

Native Xcode CLI tools (xcodebuild and xcrun simctl) provide full control over iOS/macOS builds and simulators without opening Xcode IDE. Core principle: Use CLI for automation, headless builds, and CI/CD—the same tools Xcode uses internally.

When to Use

  • Building iOS/macOS apps from command line
  • Running apps in iOS Simulator programmatically
  • Taking screenshots or recording video of simulator
  • Running unit/UI tests with specific targeting
  • Automating builds in CI/CD pipelines
  • Managing simulator instances (boot, shutdown, erase)
  • Simulating location, push notifications, or permissions
  • Capturing app logs for debugging

Symptoms that trigger this skill:

  • "Unable to find destination matching"
  • "No scheme named X found"
  • "xcodebuild: error:"
  • Need to automate Xcode workflows
  • Building without opening Xcode IDE

When NOT to Use

  • Editing code or project settings → Use Xcode IDE
  • Managing Swift Package dependencies → Use swift package CLI
  • Cross-platform builds → Use platform-specific tools
  • Signing/provisioning profile management → Use Xcode or fastlane

Quick Start

Find available simulators:

xcrun simctl list devices available

Build for simulator:

UDID=$(xcrun simctl list devices --json | jq -r '.devices | .[].[] | select(.name=="iPhone 16 Pro" and .isAvailable==true) | .udid' | head -1)
xcodebuild -workspace App.xcworkspace -scheme App -destination "platform=iOS Simulator,id=$UDID" -derivedDataPath /tmp/build build

Install and launch:

APP_PATH=$(find /tmp/build -name "*.app" -type d | head -1)
xcrun simctl install $UDID "$APP_PATH"
xcrun simctl launch --console $UDID com.bundle.identifier

Take screenshot:

xcrun simctl io $UDID screenshot /tmp/screenshot.png

Quick Reference

TaskCommand
List schemesxcodebuild -workspace App.xcworkspace -list
List simulatorsxcrun simctl list devices available
Get simulator UDIDxcrun simctl list devices --json | jq ...
Boot simulatorxcrun simctl boot $UDID
Build for simulatorxcodebuild ... -destination "platform=iOS Simulator,id=$UDID" build
Install appxcrun simctl install $UDID /path/to/App.app
Launch appxcrun simctl launch --console $UDID com.bundle.id
Take screenshotxcrun simctl io $UDID screenshot /tmp/shot.png
Run testsxcodebuild ... test
Stream logs/usr/bin/log stream --predicate 'processImagePath CONTAINS "App"'

Reference Documentation

ReferenceContents
xcodebuild.mdProject discovery, building, archiving, testing
simctl.mdDevice management, screenshots, video, location, permissions
logging.mdLog streaming and filtering predicates
workflows.mdEnd-to-end automation scripts

Common Patterns

Build + Run

  1. Find simulator UDID via simctl list devices --json
  2. Boot simulator with simctl boot $UDID
  3. Build with xcodebuild using -derivedDataPath
  4. Find .app bundle in derived data
  5. Install with simctl install
  6. Launch with simctl launch --console

Run Tests

xcodebuild -workspace App.xcworkspace -scheme App \
  -destination "platform=iOS Simulator,id=$UDID" \
  -only-testing "AppTests/SpecificTest" test

Common Mistakes

MistakeFix
"Unable to find destination"Verify simulator exists with simctl list devices. Use exact name or UDID.
"No scheme found"Run xcodebuild -list to see available schemes. Ensure you're using -workspace or -project flag.
"App not found after build"Use -derivedDataPath /tmp/build and search there with find.
Simulator not respondingTry xcrun simctl shutdown all then boot fresh.
Build succeeds but app crashesCheck xcrun simctl launch --console for runtime errors.
Tests hang indefinitelyAdd -destination-timeout flag. Ensure simulator is booted first.
Wrong simulator selectedAlways use UDID from simctl list devices --json, not device name alone.
Stale build artifactsUse clean build action or delete derived data directory.

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

95/100Analyzed 2/12/2026

A comprehensive and highly actionable guide for using Xcode CLI tools, featuring clear workflows, command references, and troubleshooting tips. It effectively bridges the gap between IDE and CLI for automation purposes.

90
95
90
90
95

Metadata

Licenseunknown
Version-
Updated2/5/2026
Publishermajiayu000

Tags

ci-cdobservabilitytesting