How to take a screenshot in the iOS Simulator (shortcut and command line)
Codemia Knowledge Hub ·
Press Command + S in the iOS Simulator to save a PNG screenshot to your desktop. For scripts and CI, run xcrun simctl io booted screenshot from the command line. In XCTest suites, XCUIScreen.main.screenshot() captures the screen so you can attach it to test results.
Keyboard shortcut: Command + S
With the Simulator in focus and your app on the screen you want:
- Press Command + S.
- The screenshot saves as a PNG file to your desktop by default.
File > Save Screenshot does the same thing. The image uses the simulated device's native resolution (for example, 1179 x 2556 for iPhone 15 Pro at 3x).
Changing where screenshots are saved
Use the defaults command to change the save location:
Create the directory first if it does not exist:
If you later delete that directory, Command + S fails silently. Recreate it, or go back to the default with defaults delete com.apple.iphonesimulator ScreenShotSaveLocation.
Command line: xcrun simctl io screenshot
simctl io captures screenshots without any GUI interaction, which makes it the tool for automation:
When several simulators are running, or to target a particular device, pass its UDID instead of booted:
The command fails with a vague error if no simulator is booted, so check xcrun simctl list devices | grep Booted before scripting captures.
Capturing every booted simulator at once
This script screenshots each booted simulator, which helps when producing App Store screenshots for several device sizes:
Screenshots inside XCTest
For automated tests, XCUIScreen captures a screenshot you can attach to the test results:
Attachments with .keepAlways appear in the Xcode Test Report and can be exported from the .xcresult bundle. With .deleteOnSuccess, screenshots from passing tests are discarded, so use .keepAlways when you need them for documentation or regression comparison.
To pull them out of the result bundle, use xcresulttool:
Recording video instead
simctl io can also record video, which is handy for interaction flows:
The video records at the device's native resolution and frame rate.
Which screenshot method to use
| Method | Best for | Automatable | Output format | Resolution |
| Command + S | Quick manual captures | No | PNG | Device native |
xcrun simctl io screenshot | CI pipelines, scripted captures | Yes | PNG, JPEG | Device native |
XCUIScreenshot in XCTest | Test documentation, regression testing | Yes | PNG (in xcresult) | Device native |
| Xcode Devices window | One-off captures during debugging | No | PNG | Device native |
Screenshot resolution by device
| Simulator device | Resolution (points) | Resolution (pixels at scale) |
| iPhone SE (3rd gen) | 375 x 667 | 750 x 1334 (2x) |
| iPhone 15 | 393 x 852 | 1179 x 2556 (3x) |
| iPhone 15 Pro Max | 430 x 932 | 1290 x 2796 (3x) |
| iPad Pro 12.9" | 1024 x 1366 | 2048 x 2732 (2x) |
The Simulator window scale (Window > Physical Size / Point Accurate / Pixel Accurate) does not change the saved resolution. Resizing the window to fit your screen has no effect; screenshots are always taken at the device's native pixel resolution.
App Store screenshots
App Store submissions need screenshots at specific device sizes. Combine simctl with fastlane snapshot to automate it:
Cleaning up the status bar
The Simulator's status bar shows "9:41 AM" by default (Apple's canonical time for marketing screenshots). To change what it shows, override the values with xcrun simctl status_bar:
Related reading
- Tap Action not working when Color is clear SwiftUI
- tap for more information or stop the app
- targetContentOffsetForProposedContentOffsetwithScrollingVelocity without subclassing UICollectionViewFlowLayout
- Task queue on Android like in GCD on iOS?
- Tensorflow - Testing a mnist neural net with my own images
- Tensorflow Is it possible to use different train input size and test input size?
- Tensorflow-Lite pretrained model does not work in Android demo
- Tensorflow Android demo Detection using Front Camera
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.