ios-simulator
The ios-simulator skill provides command-line tools for managing iOS Simulator devices and testing app behavior using `xcrun simctl`. Use it to create and manage simulator devices, deploy and launch apps, simulate push notifications and GPS locations, control privacy permissions, capture screenshots and videos, stream device logs, and perform deep-link testing without requiring Xcode's graphical interface.
git clone --depth 1 https://github.com/dpearson2699/swift-ios-skills /tmp/ios-simulator && cp -r /tmp/ios-simulator/skills/ios-simulator ~/.claude/skills/ios-simulatorSKILL.md
# iOS Simulator
Manage iOS Simulator devices and test app behavior from the command line using `xcrun simctl`. Covers the full device lifecycle, app deployment, push and location simulation, permission control, screenshot and video recording, log streaming, and compile-time simulator detection.
For common subcommands, syntax, and examples, see [references/simctl-commands.md](references/simctl-commands.md).
## Contents
- [Device Lifecycle](#device-lifecycle)
- [App Install and Launch](#app-install-and-launch)
- [Testing Workflows](#testing-workflows)
- [Screenshot and Video Recording](#screenshot-and-video-recording)
- [Log Streaming](#log-streaming)
- [Compile-Time Simulator Detection](#compile-time-simulator-detection)
- [Simulator Limitations](#simulator-limitations)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)
## Device Lifecycle
### Listing Devices and Runtimes
```bash
# List all available simulators grouped by runtime
xcrun simctl list devices available
# List installed runtimes
xcrun simctl list runtimes
# List only booted devices
xcrun simctl list devices booted
# JSON output for scripting
xcrun simctl list -j devices available
```
Parse JSON output to find a specific device programmatically. See [references/simctl-commands.md](references/simctl-commands.md) for `jq` parsing examples.
### Creating a Device
```bash
# Find available device types and runtimes
xcrun simctl list devicetypes
xcrun simctl list runtimes
# Create a device — returns the new UDID
xcrun simctl create "My Test Phone" "iPhone 16 Pro" "com.apple.CoreSimulator.SimRuntime.iOS-18-4"
```
Device types and runtime identifiers in examples throughout this skill are illustrative. Run `simctl list devicetypes` and `simctl list runtimes` to find the identifiers available on your system.
The returned UDID identifies the device for all subsequent commands. Use descriptive names to distinguish devices in `simctl list` output.
### Boot, Shutdown, Erase, Delete
```bash
# Boot a specific device
xcrun simctl boot <UDID>
# Boot if needed and wait until the device is ready
xcrun simctl bootstatus <UDID> -b
# Shutdown a running device
xcrun simctl shutdown <UDID>
# Factory reset — wipes all data, keeps the device
xcrun simctl erase <UDID>
# Delete a specific device
xcrun simctl delete <UDID>
# Delete all devices not available in the current Xcode
xcrun simctl delete unavailable
# Shutdown everything
xcrun simctl shutdown all
```
Use `booted` as a UDID shorthand when exactly one simulator is running:
```bash
xcrun simctl shutdown booted
```
If multiple simulators are booted, `booted` picks one of them non-deterministically. Prefer explicit UDIDs when running parallel simulators.
In scripts and CI, use `xcrun simctl bootstatus <UDID> -b` before install, launch, push, or location commands. If you call `simctl boot` separately, follow it with `xcrun simctl bootstatus <UDID>` before continuing.
## App Install and Launch
### Installing an App
```bash
# Build for simulator first
xcodebuild build \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
-derivedDataPath build/
# Boot and wait for SpringBoard/services before install
xcrun simctl bootstatus <UDID> -b
# Install the .app bundle
xcrun simctl install <UDID> build/Build/Products/Debug-iphonesimulator/MyApp.app
```
The path must point to a `.app` directory built for the simulator architecture, not a `.ipa` file.
### Launching and Terminating
```bash
# Launch by bundle ID
xcrun simctl launch booted com.example.MyApp
# Launch and stream stdout/stderr to the terminal
xcrun simctl launch --console booted com.example.MyApp
# Pass launch arguments
xcrun simctl launch booted com.example.MyApp --reset-onboarding -AppleLanguages "(fr)"
# Terminate a running app
xcrun simctl terminate booted com.example.MyApp
```
`--console` is useful for debugging — it shows `print()` and `os_log` output directly in the terminal.
### App Container Paths
```bash
# App bundle location
xcrun simctl get_app_container booted com.example.MyApp app
# Data container (Documents, Library, tmp)
xcrun simctl get_app_container booted com.example.MyApp data
# Shared app group container
xcrun simctl get_app_container booted com.example.MyApp group.com.example.shared
```
Use these paths to inspect sandboxed files, databases, or UserDefaults during debugging.
## Testing Workflows
### Push Notification Simulation
Create a JSON payload file:
```json
{
"aps": {
"alert": {
"title": "New Message",
"body": "You have a new message from Alice"
},
"badge": 3,
"sound": "default"
},
"customKey": "customValue"
}
```
Send it to the Simulator:
```bash
# Send push payload from file
xcrun simctl push booted com.example.MyApp payload.json
# Pipe payload from stdin
echo '{"aps":{"alert":"Quick test"}}' | xcrun simctl push booted com.example.MyApp -
```
This simulates local delivery only — no APNs connection is involved. Use this to test payload handling, notification display, and notification actions. Always verify on a real device before shipping to confirm APNs delivery works end to end.
### Location Simulation
```bash
# Set a fixed coordinate (latitude, longitude)
xcrun simctl location booted set 37.3349,-122.0090
# List available predefined scenarios
xcrun simctl location booted list
# Run a predefined scenario
xcrun simctl location booted run "City Run"
# Follow custom command-line waypoints
xcrun simctl location booted start --speed=15 --interval=1 \
37.3349,-122.0090 37.3317,-122.0307
# Read waypoints from stdin, one "lat,lon" pair per line
printf "37.3349,-122.0090\n37.3317,-122.0307\n" | \
xcrun simctl location booted start --distance=100 -
# Clear the simulated location
xcrun simctl location booted clear
```
Use `set` for one coordinate, `run` for predefined scenario names, and `start` for custom waypointDiscover and configure Bluetooth and Wi-Fi accessories using AccessorySetupKit. Use when presenting a privacy-preserving accessory picker, defining discovery descriptors for BLE or Wi-Fi devices, handling accessory session events, migrating from CoreBluetooth permission-based scanning, or setting up accessories without requiring broad Bluetooth permissions.
Implement, review, or improve Live Activities and Dynamic Island experiences in iOS apps using ActivityKit. Use when building real-time updating widgets for the Lock Screen and Dynamic Island — delivery tracking, sports scores, ride-sharing status, workout timers, media playback, or any time-sensitive information that updates in real time. Also use when working with ActivityKit, ActivityAttributes, Activity lifecycle (request/update/end), Dynamic Island layouts (compact/minimal/expanded), push-to-update Live Activities, or Lock Screen live widgets.
Measure ad effectiveness with privacy-preserving attribution using AdAttributionKit. Use when registering ad impressions, handling attribution postbacks, updating conversion values, implementing re-engagement attribution, configuring publisher or advertiser apps, or replacing SKAdNetwork with AdAttributionKit for ad measurement.
Implement AlarmKit alarms and countdown timers for iOS and iPadOS with Lock Screen, Dynamic Island, StandBy, and paired Apple Watch system UI. Covers AlarmManager scheduling, AlarmAttributes and AlarmPresentation, AlarmButton stop and snooze actions, authorization, state observation, countdown widget-extension handoff, and Live Activity integration. Use when building wake-up alarms, countdown timers, or alarm-style alerts that need Apple's system alarm experience.
Build iOS App Clips with invocation URLs, App Clip Codes, NFC, QR codes, Safari banners, Maps, Messages, target setup, App Store Connect experiences, size/capability constraints, NSUserActivity routing, SKOverlay promotion, App Group/keychain handoff, ephemeral notifications, location confirmation, and full-app migration. Use when creating App Clips or wiring App Clip invocation, experience configuration, or full-app handoff.
Implement App Intents for Siri, Shortcuts, Spotlight, widgets, Control Center, and Apple Intelligence on iOS. Covers AppIntent actions, AppEntity and EntityQuery models, AppShortcutsProvider phrases, IndexedEntity Spotlight indexing, WidgetConfigurationIntent, SnippetIntent, and assistant schemas. Use when exposing app actions or entities to system surfaces.
Optimize App Store product pages for search visibility and conversion. Use for App Store Optimization (ASO), keyword research, app name/subtitle/keyword-field strategy, conversion-focused descriptions and promotional text, screenshot captions and ordering, Custom Product Pages with assigned search keywords, In-App Events, Product Page Optimization tests, localized metadata, ratings/review strategy, and in-app review prompt timing with RequestReviewAction or AppStore.requestReview. Also use when routing ASO vs App Store review, privacy/ATT, or StoreKit implementation boundaries.
Prepare for App Store review and prevent rejections. Covers App Store review guidelines, app rejection reasons, PrivacyInfo.xcprivacy privacy manifest requirements, required API reason codes, in-app purchase IAP and StoreKit rules, App Store Guidelines compliance, ATT App Tracking Transparency, EU DMA Digital Markets Act, HIG compliance checklist, app submission preparation, review preparation, metadata requirements, entitlements, widgets, and Live Activities review rules. Use when preparing for App Store submission, fixing rejection reasons, auditing privacy manifests, implementing ATT consent flow, configuring StoreKit IAP, or checking HIG compliance.