iOS simulator
screenshots
iOS development
Xcode
app testing

Take screenshots in the iOS simulator

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

The fastest way to take a screenshot in the iOS Simulator is the keyboard shortcut Command + S, which saves a PNG to your desktop. For automated workflows and CI pipelines, use xcrun simctl io booted screenshot to capture screenshots from the command line. For integration test suites, XCUIScreenshot lets you capture and attach screenshots programmatically during test execution.

Method 1: Keyboard Shortcut (Command + S)

With the Simulator in focus and your app showing the screen you want to capture:

  1. Press Command + S.
  2. The screenshot saves as a PNG file to your desktop by default.

You can also use the menu: File > Save Screenshot. The behavior is identical. The saved image matches the simulated device's native resolution (for example, 1179 x 2556 for iPhone 15 Pro at 3x).

Changing the Default Save Location

The Simulator saves screenshots to your desktop. To change this, use the defaults command:

bash
1# Save screenshots to a custom directory
2defaults write com.apple.iphonesimulator ScreenShotSaveLocation ~/Screenshots/simulator
3
4# Verify the setting
5defaults read com.apple.iphonesimulator ScreenShotSaveLocation

Create the directory first if it does not exist:

bash
mkdir -p ~/Screenshots/simulator

Method 2: Command Line with xcrun simctl

The simctl io subcommand captures screenshots without GUI interaction, making it ideal for automation.

bash
1# Save to a specific file path
2xcrun simctl io booted screenshot ~/Desktop/login-screen.png
3
4# Capture with a specific image type
5xcrun simctl io booted screenshot --type=jpeg ~/Desktop/login-screen.jpg
6
7# Target a specific simulator by UDID
8xcrun simctl io booted screenshot --type=png /tmp/screenshot.png

To capture from a simulator that is not currently booted or when multiple simulators are running, specify the UDID:

bash
1# List running simulators
2xcrun simctl list devices | grep Booted
3
4# Capture from a specific device
5xcrun simctl io 4A2B3C4D-5E6F-7890-ABCD-EF1234567890 screenshot output.png

Capturing Screenshots Across Multiple Devices

This script captures screenshots from every booted simulator, useful for generating App Store screenshots across device sizes:

bash
1#!/bin/bash
2OUTPUT_DIR="./screenshots/$(date +%Y%m%d_%H%M%S)"
3mkdir -p "$OUTPUT_DIR"
4
5xcrun simctl list devices | grep "Booted" | while read -r line; do
6  UDID=$(echo "$line" | grep -oE '[A-F0-9-]{36}')
7  NAME=$(echo "$line" | sed 's/ (.*//' | xargs)
8  FILENAME=$(echo "$NAME" | tr ' ' '_')
9  xcrun simctl io "$UDID" screenshot "$OUTPUT_DIR/${FILENAME}.png"
10  echo "Captured: $NAME"
11done

Method 3: Programmatic Screenshots in XCTest

For automated testing, XCUIScreen provides screenshot capture that can be attached to test results.

swift
1import XCTest
2
3class ScreenshotTests: XCTestCase {
4    func testLoginScreenLayout() {
5        let app = XCUIApplication()
6        app.launch()
7
8        // Navigate to the screen you want to capture
9        app.textFields["email"].tap()
10
11        // Take a screenshot
12        let screenshot = XCUIScreen.main.screenshot()
13
14        // Attach it to the test results
15        let attachment = XCTAttachment(screenshot: screenshot)
16        attachment.name = "Login Screen"
17        attachment.lifetime = .keepAlways
18        add(attachment)
19    }
20}

Screenshots attached with .keepAlways appear in the Xcode Test Report and can be exported from the .xcresult bundle.

Extracting Screenshots from Test Results

After running tests, extract screenshots from the result bundle using xcresulttool:

bash
1# Find the result bundle
2ls ~/Library/Developer/Xcode/DerivedData/*/Logs/Test/*.xcresult
3
4# Export all attachments
5xcrun xcresulttool get --path <result-bundle>.xcresult --format json

Method 4: Recording Video (Bonus)

While not a screenshot, simctl io also supports video recording, which is useful for capturing interaction flows:

bash
1# Start recording
2xcrun simctl io booted recordVideo ~/Desktop/demo.mov
3
4# Press Ctrl+C to stop recording

The video records at the device's native resolution and frame rate.

Comparison of Screenshot Methods

MethodBest forAutomatableOutput formatResolution
Command + SQuick manual capturesNoPNGDevice native
xcrun simctl io screenshotCI pipelines, scripted capturesYesPNG, JPEGDevice native
XCUIScreenshot in XCTestTest documentation, regression testingYesPNG (in xcresult)Device native
Xcode Devices windowOne-off captures during debuggingNoPNGDevice native

Screenshot Resolution by Device

Simulator deviceResolution (points)Resolution (pixels at scale)
iPhone SE (3rd gen)375 x 667750 x 1334 (2x)
iPhone 15393 x 8521179 x 2556 (3x)
iPhone 15 Pro Max430 x 9321290 x 2796 (3x)
iPad Pro 12.9"1024 x 13662048 x 2732 (2x)

The Simulator window scale (Window > Physical Size / Point Accurate / Pixel Accurate) does not affect the saved screenshot resolution. Screenshots always capture at the device's native pixel resolution.

Generating App Store Screenshots

For App Store submission, you need screenshots at specific device sizes. Combine simctl with fastlane snapshot for a fully automated workflow:

bash
1# Using fastlane snapshot (after configuring Snapfile)
2fastlane snapshot
3
4# Or manually boot specific devices and capture
5xcrun simctl boot "iPhone 15 Pro"
6xcrun simctl boot "iPhone 15 Pro Max"
7xcrun simctl boot "iPad Pro (12.9-inch) (6th generation)"
8
9# Launch your app on each and capture
10for DEVICE in $(xcrun simctl list devices booted -j | jq -r '.devices[][] | select(.state=="Booted") | .udid'); do
11  xcrun simctl io "$DEVICE" screenshot "./appstore_${DEVICE}.png"
12done

Common Pitfalls

Capturing at the wrong window scale. Developers sometimes resize the Simulator window to fit their screen and assume the screenshot resolution changes. It does not. Screenshots always use the device's native resolution regardless of the window scale setting.

Screenshots include the status bar. The Simulator's status bar shows "9:41 AM" by default (Apple's canonical time for marketing screenshots). If you need to hide or customize it, use xcrun simctl status_bar to override displayed values:

bash
1xcrun simctl status_bar booted override \
2  --time "9:41" \
3  --batteryState charged \
4  --batteryLevel 100 \
5  --cellularMode active \
6  --cellularBars 4

Forgetting to reset the screenshot directory. If you change the save location with defaults write and later delete that directory, Command + S will silently fail. Verify the directory exists or reset to the default with defaults delete com.apple.iphonesimulator ScreenShotSaveLocation.

XCTest screenshots not appearing in results. If you use .deleteOnSuccess as the attachment lifetime, screenshots from passing tests are discarded. Use .keepAlways when you need screenshots for documentation or regression comparison.

Running simctl screenshot against a shutdown simulator. The command fails with a vague error if no simulator is booted. Always check xcrun simctl list devices | grep Booted before scripting captures.

Summary

For manual captures during development, Command + S is the simplest option and saves PNG files at device-native resolution. For CI and automation, xcrun simctl io booted screenshot provides scriptable, format-configurable captures that work without GUI interaction. For test suites, use XCUIScreenshot to attach captures to test results for visual regression tracking. Screenshots always render at the simulated device's native resolution regardless of the Simulator window size, and you can control status bar content with simctl status_bar for clean App Store screenshots.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.