Advanced screenshot and screen capture from your iOS Simulator
You may sometimes need to take screenshots or video captures of your app, wether it’s on iOS, tvOS or watchOS.
It’s easy to do so from an iPhone or iPad, but maybe a little more difficult on an Apple Watch or Apple TV.
Although Apple gives simple access to screenshot from the Simulator, some more advanced options are available with command lines.
You will only need your Simulator to be launched.
Just open a Terminal and use the following command-line.
$ xcrun simctl io booted screenshot Screenshot.png
This will save your screenshot in the current directory.
Image format is png by default, but the xcrun tool will automatically detect the image format you need from the filename extension you will provide.
Supported image formats are:
If you have an iPhone X/Xs/Xr, the notch may be an issue for your screenshot.
You can provide a
--mask option with one of the following values:
ignored: this is the default value. No mask will be applied.
alpha: the corners and notch areas will be transparent in your output file.
black: the corners and notch areas will be black in your output file.
$ xcrun simctl io booted screenshot --mask alpha Screenshot.png
Just like screenshots, use the following command-line:
$ xcrun simctl io booted recordVideo Capture.mp4
To stop recording, just do
The following extensions will be supported and detected for the output video format:
mp4 being the default value.
Mask options are also available for video capture with the
--mask option by providing one of the following value.
ignored: no mask will be applied.
black: default value, the corners and notch areas will be black in your output file.
$ xcrun simctl io booted recordVideo --mask ignored Capture.mp4
Wether it’s for a submission on the App Store, generating videos for your GIF previews on your README.md, demo to your teams (or sometimes Apple’s App Store reviewers), this command line will be a great tool for any developer.
Knowing these tips may also save you some time since the Screenshot feature from the Simulator only saves the image in your Pasteboard.
It will also offer you the possibility to directly chose the output file format.