ios-simulator
SKILL.md
iOS Simulator Testing
When to Use This Skill
- Testing iOS applications locally
- Taking screenshots of app states
- Simulating user interactions
- Testing different device sizes
- Debugging mobile UI issues
- Recording app demonstrations
Prerequisites
# Ensure Xcode is installed
xcode-select --install
# List available simulators
xcrun simctl list devices
# List available runtimes
xcrun simctl list runtimes
Simulator Management
Boot & Shutdown
# Boot a specific simulator
xcrun simctl boot "iPhone 15 Pro"
# Boot by UDID
xcrun simctl boot 12345678-1234-1234-1234-123456789012
# Open Simulator app (shows booted devices)
open -a Simulator
# Shutdown
xcrun simctl shutdown "iPhone 15 Pro"
# Shutdown all
xcrun simctl shutdown all
# Erase (reset to factory)
xcrun simctl erase "iPhone 15 Pro"
Create Custom Simulators
# List device types
xcrun simctl list devicetypes
# Create new simulator
xcrun simctl create "My Test iPhone" "iPhone 15 Pro" "iOS 17.0"
# Delete simulator
xcrun simctl delete "My Test iPhone"
App Installation & Launch
# Install app
xcrun simctl install booted /path/to/MyApp.app
# Uninstall app
xcrun simctl uninstall booted com.company.myapp
# Launch app
xcrun simctl launch booted com.company.myapp
# Launch with arguments
xcrun simctl launch booted com.company.myapp --arg1 value1
# Terminate app
xcrun simctl terminate booted com.company.myapp
Screenshots & Recording
# Take screenshot
xcrun simctl io booted screenshot screenshot.png
# Take screenshot of specific device
xcrun simctl io "iPhone 15 Pro" screenshot ~/Desktop/screenshot.png
# Record video
xcrun simctl io booted recordVideo video.mov
# Stop recording with Ctrl+C
# Or specify duration
timeout 10 xcrun simctl io booted recordVideo demo.mov
User Interaction Simulation
Location
# Set location (latitude, longitude)
xcrun simctl location booted set 37.7749,-122.4194
# Set to Apple Park
xcrun simctl location booted set 37.334606,-122.009102
# Clear location
xcrun simctl location booted clear
Push Notifications
# Create notification payload
cat > notification.json << EOF
{
"aps": {
"alert": {
"title": "Test Notification",
"body": "This is a test push notification"
},
"badge": 1,
"sound": "default"
},
"custom_key": "custom_value"
}
EOF
# Send notification
xcrun simctl push booted com.company.myapp notification.json
URL Schemes
# Open URL
xcrun simctl openurl booted "myapp://deep/link"
# Open web URL
xcrun simctl openurl booted "https://example.com"
Privacy Permissions
# Grant permission
xcrun simctl privacy booted grant photos com.company.myapp
xcrun simctl privacy booted grant camera com.company.myapp
xcrun simctl privacy booted grant microphone com.company.myapp
xcrun simctl privacy booted grant location com.company.myapp
# Revoke permission
xcrun simctl privacy booted revoke photos com.company.myapp
# Reset all permissions
xcrun simctl privacy booted reset all com.company.myapp
Keychain
# Add root certificate
xcrun simctl keychain booted add-root-cert certificate.pem
# Add certificate
xcrun simctl keychain booted add-cert certificate.pem
Data Management
App Data
# Get app container path
xcrun simctl get_app_container booted com.company.myapp data
# Get app bundle path
xcrun simctl get_app_container booted com.company.myapp app
# List installed apps
xcrun simctl listapps booted
Photos & Media
# Add photos to library
xcrun simctl addmedia booted photo1.jpg photo2.png
# Add video
xcrun simctl addmedia booted video.mp4
Clipboard
# Get clipboard contents
xcrun simctl pbpaste booted
# Set clipboard
xcrun simctl pbcopy booted "Text to copy"
Status Bar Customization
# Override status bar (for screenshots)
xcrun simctl status_bar booted override \
--time "9:41" \
--batteryState charged \
--batteryLevel 100 \
--wifiBars 3 \
--cellularBars 4
# Clear status bar overrides
xcrun simctl status_bar booted clear
Accessibility
# Enable VoiceOver
xcrun simctl spawn booted defaults write com.apple.Accessibility VoiceOverTouchEnabled -bool true
# Disable VoiceOver
xcrun simctl spawn booted defaults write com.apple.Accessibility VoiceOverTouchEnabled -bool false
Diagnostics
# Get diagnostic report
xcrun simctl diagnose
# Spawn shell command in simulator
xcrun simctl spawn booted log stream --level debug
# View logs
xcrun simctl spawn booted log show --predicate 'subsystem == "com.company.myapp"'
Automation Scripts
Test Multiple Devices
#!/bin/bash
devices=("iPhone 15 Pro" "iPhone 15" "iPhone SE (3rd generation)")
for device in "${devices[@]}"; do
echo "Testing on $device..."
xcrun simctl boot "$device"
xcrun simctl install booted MyApp.app
xcrun simctl launch booted com.company.myapp
sleep 5
xcrun simctl io booted screenshot "screenshot_${device// /_}.png"
xcrun simctl shutdown "$device"
done
Clean Test Environment
#!/bin/bash
# Reset simulator to clean state
xcrun simctl shutdown all
xcrun simctl erase all
xcrun simctl boot "iPhone 15 Pro"
xcrun simctl install booted MyApp.app
xcrun simctl privacy booted grant all com.company.myapp
Common Device UDIDs
Use xcrun simctl list devices to get current UDIDs, as they vary by installation.
Best Practices
- Use specific device names/UDIDs in scripts
- Reset simulator state between test runs
- Set consistent status bar for screenshots
- Test on multiple device sizes
- Clear app data before critical tests
- Use
bootedkeyword for current device - Automate repetitive testing tasks