Agent SkillsPrisma-Labs-Dev/apple-skills › simulator-utils

simulator-utils

GitHub

提供iOS模拟器常用操作命令参考,涵盖设备管理、应用安装启动、截图(含自动缩放适配API限制)、视频录制及构建流程,辅助开发者高效进行模拟器自动化与调试工作。

skills/simulator-utils/SKILL.md Prisma-Labs-Dev/apple-skills

Trigger Scenarios

需要截取iOS模拟器屏幕图片 调整模拟器截图尺寸以符合API要求 在模拟器中安装或运行App 清理或重置模拟器环境 使用命令行构建iOS项目

Install

npx skills add Prisma-Labs-Dev/apple-skills --skill simulator-utils -g -y
More Options

Use without installing

npx skills use Prisma-Labs-Dev/apple-skills@simulator-utils

指定 Agent (Claude Code)

npx skills add Prisma-Labs-Dev/apple-skills --skill simulator-utils -a claude-code -g -y

安装 repo 全部 skill

npx skills add Prisma-Labs-Dev/apple-skills --all -g -y

预览 repo 内 skill

npx skills add Prisma-Labs-Dev/apple-skills --list

SKILL.md

Frontmatter
{
    "name": "simulator-utils",
    "description": "iOS Simulator utility commands for screenshots, resizing, and common operations. Use these commands when taking simulator screenshots, resizing images for API compatibility, or performing common simulator operations.",
    "user-invocable": true
}

Simulator Utilities

Quick reference for iOS Simulator commands. Use these patterns whenever working with simulators.

Screenshot with Auto-Resize (REQUIRED)

ALWAYS use this pattern when taking screenshots to avoid API errors:

# Single command: screenshot + resize
xcrun simctl io booted screenshot /path/to/screenshot.png && sips --resampleHeightWidthMax 1800 /path/to/screenshot.png

Why Resize?

  • iPhone 17 simulator screenshots exceed 2000px
  • Claude API rejects images >2000px in multi-image requests
  • sips --resampleHeightWidthMax 1800 keeps images under limit

Resize Existing Screenshots

# Single file
sips --resampleHeightWidthMax 1800 /path/to/screenshot.png

# Multiple files
sips --resampleHeightWidthMax 1800 /path/to/*.png

# Batch resize all PNGs in directory
for f in /path/to/dir/*.png; do sips --resampleHeightWidthMax 1800 "$f"; done

Common Simulator Commands

Device Management

# List available simulators
xcrun simctl list devices available

# Boot specific device (prefer iPhone 17)
xcrun simctl boot "iPhone 17"

# Shutdown simulator
xcrun simctl shutdown booted

# Erase simulator (fresh state)
xcrun simctl erase "iPhone 17"

# Check booted device
xcrun simctl list devices | grep Booted

App Operations

# Install app
xcrun simctl install booted /path/to/App.app

# Launch app
xcrun simctl launch booted com.bundle.identifier

# Terminate app
xcrun simctl terminate booted com.bundle.identifier

# Uninstall app
xcrun simctl uninstall booted com.bundle.identifier

Screenshots

# Basic screenshot (NOT recommended - use resize pattern above)
xcrun simctl io booted screenshot /path/to/screenshot.png

# Screenshot with resize (RECOMMENDED)
xcrun simctl io booted screenshot /path/to/screenshot.png && sips --resampleHeightWidthMax 1800 /path/to/screenshot.png

# Screenshot to clipboard
xcrun simctl io booted screenshot - | pbcopy

Video Recording

# Start recording
xcrun simctl io booted recordVideo /path/to/video.mov

# Stop recording: Ctrl+C

Build Commands

# Build for simulator
xcodebuild -scheme SCHEME -project /path/to/Project.xcodeproj -destination 'platform=iOS Simulator,name=iPhone 17' build

# Build with output filtering (cleaner)
xcodebuild -scheme SCHEME -project /path/to/Project.xcodeproj -destination 'platform=iOS Simulator,name=iPhone 17' build 2>&1 | grep -E "(error:|warning:|BUILD)"

# Find built .app path
find ~/Library/Developer/Xcode/DerivedData -name "*.app" -path "*/Debug-iphonesimulator/*" -type d 2>/dev/null | head -1

Full Test Workflow

Complete pattern for build, install, launch, screenshot:

# 1. Build
xcodebuild -scheme SCHEME -project /path/to/Project.xcodeproj -destination 'platform=iOS Simulator,name=iPhone 17' build 2>&1 | grep -E "(error:|BUILD)"

# 2. Terminate existing instance (ignore errors)
xcrun simctl terminate booted com.bundle.identifier 2>/dev/null

# 3. Install
xcrun simctl install booted "/path/to/App.app"

# 4. Launch
xcrun simctl launch booted com.bundle.identifier

# 5. Wait for app to load
sleep 2

# 6. Screenshot with resize
xcrun simctl io booted screenshot /path/to/screenshot.png && sips --resampleHeightWidthMax 1800 /path/to/screenshot.png

Image Manipulation with sips

sips (Scriptable Image Processing System) is macOS built-in:

# Resize to max dimension (maintains aspect ratio)
sips --resampleHeightWidthMax 1800 image.png

# Resize to specific width
sips --resampleWidth 1000 image.png

# Resize to specific height
sips --resampleHeight 1000 image.png

# Get image dimensions
sips -g pixelWidth -g pixelHeight image.png

# Convert format
sips -s format jpeg image.png --out image.jpg

# Batch resize
sips --resampleHeightWidthMax 1800 *.png

Troubleshooting

"No devices are booted"

xcrun simctl boot "iPhone 17"

Screenshot too large for API

sips --resampleHeightWidthMax 1800 /path/to/screenshot.png

App won't launch

# Check bundle ID
xcrun simctl listapps booted | grep -A5 "CFBundleIdentifier"

# Reinstall
xcrun simctl uninstall booted com.bundle.identifier
xcrun simctl install booted /path/to/App.app

Simulator stuck

xcrun simctl shutdown all
xcrun simctl erase all
xcrun simctl boot "iPhone 17"

Version History

  • a76633b Current 2026-07-25 07:01

Same Skill Collection

disabled-skills/guide-swiftui-view-refactor/SKILL.md
disabled-skills/ios-design-consultant/SKILL.md
disabled-skills/ios-ui-craft/SKILL.md
skills/appintents/SKILL.md
skills/apple-aso/SKILL.md
skills/apple-docs-index/SKILL.md
skills/backgroundtasks/SKILL.md
skills/combine/SKILL.md
skills/core-animation/SKILL.md
skills/corehaptics/SKILL.md
skills/eventkit/SKILL.md
skills/guide-macos-spm-packaging/SKILL.md
skills/guide-swift-concurrency/SKILL.md
skills/guide-swift-testing/SKILL.md
skills/guide-swiftdata/SKILL.md
skills/guide-swiftui-animations/SKILL.md
skills/guide-swiftui-charts/SKILL.md
skills/guide-swiftui-performance-audit/SKILL.md
skills/guide-swiftui-ui-patterns/SKILL.md
skills/healthkit/SKILL.md
skills/hig/SKILL.md
skills/ios-dev/SKILL.md
skills/ios-liquid-glass/SKILL.md
skills/mapkit/SKILL.md
skills/photosui/SKILL.md
skills/storekit/SKILL.md
skills/swift-concurrency/SKILL.md
skills/swift-testing/SKILL.md
skills/swiftdata/SKILL.md
skills/swiftui/SKILL.md
skills/tipkit/SKILL.md
skills/uikit/SKILL.md
skills/usernotifications/SKILL.md
skills/widgetkit/SKILL.md
skills/xcuitest/SKILL.md

Metadata

Files
0
Version
a76633b
Hash
f1aed776
Indexed
2026-07-25 07:01

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 04:43
浙ICP备14020137号-1 $mapa de visitantes$