Interacting with the iOS Simulator from the Command Line using simctl

Wasn’t aware of this, but turns out one can control (and interact with) the iOS Simulator straight from the command line.

There’s no need to install anything new though. The tool we’re going to be using is already on our Mac, hiding inside the xcrun command, which gets installed with Xcode.

It’s called simctl.

Here’s a few examples:

# open a URL
xcrun simctl openurl booted ""

# upload an image to the iOS Simulator
xcrun simctl addmedia booted ~/images/image1.png ~/images/image2.jpg

# Take a screenshot
xcrun simctl io booted screenshot ~/Desktop/screenshot.png

# Record a video
xcrun simctl io booted recordVideo --type=mp4 ~/Desktop/movie.mp4

Other commands include booting/stopping a device, clipboard operations, launching/terminating processes, installing/uninstalling apps, etc. — No touch events though, that would’ve been real fun.

Little bits of Cocoa: Interacting with the iOS Simulator using simctl

Sidenote: digging a bit deeper into this I stumbled upon fbsimctl. Their features are quite the same which makes me wonder if fbsimctl uses simctl underneath its hood, or if simctl came later and copied features from fbsimctl.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.