How to take a screenshot or record a video of iOS Simulator

Xcode Location

f you want to take a screenshot of iOS Simulator or record a video, you can do it by using the utility simctl from the Terminal which allows us to control the simulator with commands.

Take Screenshot

There are two methods to take a screenshot. One, from the Menu Bar, and two, through Terminal.

Taking Screenshot from the Menu Bar

All you have to do to take a screenshot is go to the menu bar and press File>Save Screen, or use the shortcut command ⌘ + S

Save screen with iOS Simulator

You can find the screenshot image on your Desktop.

Taking Screenshot using Terminal

While you have the iOS Simulator open, go to the Terminal (Launchpad>Terminal), and type the following to take a screenshot in .png format and with name myscreenshot:

xcrun simctl io booted screenshot myscreenshot.png
Take a screenshot of the Simulator for Terminal

You can find the file in the Home folder (Finder > Go > Home).

You can also take screenshots in other types, like .jpg. Type in the Terminal the following to see the supported formats:

xcrun simctl help io

Record Video

To record video, you can do it only through Terminal by typing:

xcrun simctl io booted recordVideo <filename>.<file extension>

Replace <filename> with the name you want and <file extension> with .mov

Create a video from Terminal for Simulator in iOS

And press Control+C to stop recording.

The file is inside the Home folder (Finder > Go > Home)

The exported file is in hevc codec, if you want different codec, type the following to see the list:

xcrun simctl help io

Troubleshooting

Unable to find utility “simctl”

When you try to use any of the above commands in Terminal, may you get as a result the following error:

xcrun: error: unable to find utility “simctl”, not a developer tool or in PATH

To fix that, go to Xcode and Preferences > Locations and in Command Line Tools choose your Xcode version:

Xcode Preferences > Location for Command Line Tools

Leave a Reply

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