Section 11/181 menit
11. Simulator Productivity
11. Simulator Productivity
simctl: Control Simulator dari Terminal
swift
# List semua simulator
xcrun simctl list devices
# Boot simulator spesifik
xcrun simctl boot "iPhone 15 Pro"
# Install app ke simulator
xcrun simctl install booted MyApp.app
# Jalankan app
xcrun simctl launch booted com.mycompany.myapp
# Push notification simulasi
xcrun simctl push booted com.mycompany.myapp notification.apns
# Buat file notification.apns:
# {
# "aps": {
# "alert": {
# "title": "Test Notification",
# "body": "Ini adalah test push notification"
# },
# "badge": 1,
# "sound": "default"
# }
# }
# Screenshot
xcrun simctl io booted screenshot ~/Desktop/screenshot.png
# Record video
xcrun simctl io booted recordVideo ~/Desktop/demo.mp4
# Set status bar (untuk screenshot yang bersih)
xcrun simctl status_bar booted override \
--time "9:41" \
--batteryState charged \
--batteryLevel 100 \
--cellularMode active \
--cellularBars 4
# Reset status bar
xcrun simctl status_bar booted clear
# Erase semua data simulator (fresh install)
xcrun simctl erase booted
# Delete semua simulator yang tidak terpakai
xcrun simctl delete unavailable
Deep Link Testing
swift
# Test URL scheme / universal link di simulator
xcrun simctl openurl booted "myapp://profile/user123"
# Test universal link (butuh server dengan apple-app-site-association)
xcrun simctl openurl booted "https://myapp.com/profile/user123"
Location Simulation
swift
# Set lokasi GPS simulator
xcrun simctl location booted set 37.3318 -122.0312 # Apple HQ
# Jalankan GPX route
xcrun simctl location booted run route.gpx
# Contoh route.gpx:
# <?xml version="1.0"?>
# <gpx version="1.1">
# <trk><trkseg>
# <trkpt lat="-6.2088" lon="106.8456"><ele>10</ele></trkpt>
# <trkpt lat="-6.2100" lon="106.8470"><ele>10</ele></trkpt>
# </trkseg></trk>
# </gpx>