Take a screenshot and record a video in iOS Simulator
Table of Contents
There would be a time when you need to capture your app screen or record a video of your app, whether for an App Store screenshot or an App Store preview video. You can do all of this without external tools.
Take a screenshot
An easy way
For taking a screenshot, I usually launch an app in the Simulator and press ⌘ - command + s or File > New Screen Shot. The screenshot will be saved to your Desktop.
Xcrun
xcrun is a tool Apple provided to run any tool inside Xcode from the command line.
- To take a screenshot with xcrun.
- Run your app in the Simulator.
- Open Terminal.app (located in /Applications/Utilities)
- Enter the following command and hit ⏎ Return.
xcrun simctl io booted screenshot <file_name>.<file_extension>
The screenshot will be saved to your current directory. If you don't know where is the current directory, type pwd
in Terminal.app and press ⏎ Return.
Example
xcrun simctl io booted screenshot myScreenshot.png
Options
You can specify the following options to the command.
--type
Can be "png", "tiff", "bmp", "gif", "jpeg". Default is png.--display
- iOS: supports "internal" or "external". Default is "internal".
- tvOS: supports only "external"
- watchOS: supports only "internal"
--mask
For non-rectangular displays, handle the mask by policy:- ignored: The mask is ignored and the unmasked framebuffer is saved.
- alpha: The mask is used as premultiplied alpha.
- black: The mask is rendered black.
Example
The following example will take a jpeg screenshot with a mask (see round corners and a notch).
xcrun simctl io booted screenshot --type=jpeg --mask=black myScreenshot.jpeg
You can easily support sarunw.com by checking out this sponsor.
Screenshot Studio: Create App Store screenshots in seconds not minutes.
Record a video
Xcrun
When it comes to recording a video, xcrun is an easy way for me (I used to record video with Quicktime, but I find it quite cumbersome).
- Run your app in the Simulator.
- Open Terminal.app (located in /Applications/Utilities)
- Enter the following command and hit ⏎ Return.
xcrun simctl io booted recordVideo <file_name>.<file_extension>
- Press ⌃ – control + c to stop recording the video.
The video will be saved to your current directory. If you don't know where is the current directory, type pwd
in Terminal.app and press ⏎ Return.
Example
xcrun simctl io booted recordVideo myVideo.mov
Options
You can specify the following options to the command.
--codec
Specifies the codec type: "h264" or "hevc". Default is "hevc".--display
- iOS: supports "internal" or "external". Default is "internal".
- tvOS: supports only "external"
- watchOS: supports only "internal"
--mask
For non-rectangular displays, handle the mask by policy:- ignored: The mask is ignored and the unmasked framebuffer is saved.
- alpha: Not supported, but retained for compatibility; the mask is rendered black.
- black: The mask is rendered black.
--force
Force the output file to be written to, even if the file already exists.
Example
xcrun simctl io booted recordVideo --code=h264 --mask=black --force myVideo.mov
All xcrun command might vary based on your Xcode and mac version. For more information, run this command:
xcrun simctl io help
You can easily support sarunw.com by checking out this sponsor.
Screenshot Studio: Create App Store screenshots in seconds not minutes.
Related Resources
Read more article about Simulator, Video, Screenshot, or see all available topic
Enjoy the read?
If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.
Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.
If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.
Become a patron Buy me a coffee Tweet ShareUINavigationBar changes in iOS13, Part2: UISearchController
Revisit of navigation bar appearance — this time with a UISearchController. If you have a search bar in your navigation bar, you might need to recheck when you build your app against iOS13.