iOS simulator command line tricks

CLI commands are always handy to speed up your work and even things beyond interface provides, so here I have mentioned few commands which can make your day. Also if you are planning to setup your CI these are very helpful. So open your mac terminal and go for it.

Xcode and simulator side by side

defaults write AllowFullscreenMode -bool YES

List all simulators created

xcrun simctl list --json

Get rid of all unused simlators

When you print the list of all devices through above command you might find few unavailable devices, these are leftovers from your previous update of xcode.

xcrun simctl delete unavailable

Launch simulator app

open /Applications/

Launch multiple simulators

find simulator id’s from the ‘xcrun simctl list’ command

xcrun simctl boot 12F3C6FB-1A8A-4D20-922F-2DB485F58F0F
xcrun simctl boot BE53CBFF-4900-4F10-A1D4-B451AB4C9E7E
open /Applications/

Here onwards if you see the word booted in command that means your simulator should be already launched

Record simulator video

xcrun simctl io booted recordVideo — type=mp4 ./test.mp4

Screenshot of simulator

Simply press ⌘ + S on your keyboard and screenshot will be saved on desktop or

xcrun simctl io booted screenshot ./screen.png

Open URL in simulator

Launch any url or you can use url scheme to launch your app directly

xcrun simctl openurl booted
xcrun simctl openurl booted myapp://

Upload photo or video file to photos app

xcrun simctl addmedia booted ./test.mp4

Find the app container

just change com.bundle.identifier to your apps bundle identifier

xcrun simctl get_app_container booted com.bundle.identifier
output of get_app_container

Stream simulator logs

This command will save the output in test.log file and open mac console app to view log stream

`xcrun simctl spawn booted log stream > test.log&`; open test.log;

Filter logs

xcrun simctl spawn booted log stream --predicate 'eventMessage contains "com.itkan.awesome"'
filtered output

The below command will help you know fields for creating the needed predicate

xcrun simctl spawn booted log stream --style=json
output json

Do you want to explore more? Go ahead and enter below command

xcrun simctl help