Last updated on: May 27, 2023
In this tutorial, we will learn how to take a screenshot and record a video of the iOS Simulator using both the built-in Simulator app options and Terminal commands. This can be helpful when creating visual documentation, reporting bugs, or showcasing your apps.
Contents
iOS Simulator
Taking a Screenshot
- Launch the iOS Simulator by opening Xcode and selecting the simulator device you want to use from the active scheme menu, or by running
open -a Simulator
in Terminal. - Run the app or navigate to the screen you want to capture.
- In the Simulator’s menu bar, click “File” and then select “Save Screen”.
- Choose the destination folder, and save the screenshot as a PNG file.
Recording a Video
- Open the iOS Simulator and run your app or navigate to the screen you want to record.
- In the Simulator’s menu bar, click “File” and then select “Record Screen”.
- A red circle will appear in the top-right corner of the Simulator window, indicating that the recording has started.
- To stop recording, click “File” in the menu bar again and select “Stop Recording”. The recorded video will be saved as an MOV file in your Movies folder by default.
Terminal Commands
Taking a Screenshot
Option 1: Take a screenshot using the simulator UDID
- Open Terminal and find the device identifier (UDID) of the simulator you want to capture by running
xcrun simctl list
. - Take a screenshot using the following command, replacing
your_simulator_UDID
with the UDID andoutput_file_path.png
with the desired output file path:
xcrun simctl io your_simulator_UDID screenshot output_file_path.png
Option 2: Take a screenshot of the currently booted simulator
- Open Terminal.
- Run the following command to take a screenshot of the currently booted simulator. Replace
output_file_path.png
with the desired output file path:
xcrun simctl io booted screenshot output_file_path.png
Recording a Video
Option 1: Record a video using the simulator UDID
- Open Terminal and find the device identifier (UDID) of the simulator you want to record by running
xcrun simctl list
. - Start recording the simulator using the following command, replacing
your_simulator_UDID
with the UDID andoutput_file_path.mov
with the desired output file path:
xcrun simctl io your_simulator_UDID recordVideo output_file_path.mov
Option 2: Record a video of the currently booted simulator
- Open Terminal.
- Run the following command to start recording a video of the currently booted simulator. Replace
output_file_path.mov
with the desired output file path:
xcrun simctl io booted recordVideo output_file_path.mov
- To stop the recording, press
Ctrl+C
in the Terminal window.
If you have any questions, please feel free to leave a comment below