simulator-utils について
simulator-utils は、iOS Simulator の操作やビルド手順をまとめたスキルです。シミュレーター上でアプリを開発・テストする開発者向けに、デバイス操作や画像サイズを調整したスクリーンショットの撮影方法を案内します。
主な機能
- 01シミュレーターデバイスの管理
- 02アプリのインストールと起動コマンド
- 03スクリーンショットの撮影とリサイズ
- 04動画録画コマンド
- 05Xcode のビルドとテスト手順
- 06sips による画像リサイズ
活用シーン
- 01シミュレーターの起動やリセット
- 02ビルド済みアプリのインストールと起動
- 03API のサイズ要件に合うスクリーンショットの撮影
- 04シミュレーター上のアプリ操作の録画
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ prisma-labs-dev/ apple-skills --skill simulator-utilsインストール後、Claude Code で/simulator-utilsを入力して読み込まれたか確認します。
詳細
シミュレーターのユーティリティ
iOS シミュレーターのコマンドをすぐに確認できます。シミュレーターを操作する際は、必ずこれらのパターンを使用してください。
自動リサイズ付きのスクリーンショット(必須)
スクリーンショットを撮影する際は、API エラーを避けるために必ずこのパターンを使用してください。
# Single command: screenshot + resize
xcrun simctl io booted screenshot /path/to/screenshot.png && sips --resampleHeightWidthMax 1800 /path/to/screenshot.png
リサイズが必要な理由
- iPhone 17 のシミュレーターのスクリーンショットは 2000px を超えます
- Claude API は、複数画像のリクエストで 2000px を超える画像を拒否します
sips --resampleHeightWidthMax 1800を使うと、画像を上限未満に保てます
既存のスクリーンショットをリサイズする
# 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
よく使うシミュレーターコマンド
デバイス管理
# 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
アプリの操作
# 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
スクリーンショット
# 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
動画の録画
# Start recording
xcrun simctl io booted recordVideo /path/to/video.mov
# Stop recording: Ctrl+C
ビルドコマンド
# 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
テストの一連のワークフロー
ビルド、インストール、起動、スクリーンショット撮影を行う一連の手順:
# 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
sips による画像操作
sips(Scriptable Image Processing System)は macOS に標準搭載されています。
# 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
トラブルシューティング
「No devices are booted」
xcrun simctl boot "iPhone 17"
API に送信するにはスクリーンショットが大きすぎる
sips --resampleHeightWidthMax 1800 /path/to/screenshot.png
アプリが起動しない
# 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
シミュレーターが応答しない
xcrun simctl shutdown all
xcrun simctl erase all
xcrun simctl boot "iPhone 17"
コメント
Markdown 対応