What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The right Swift screenshot API depends on who starts the capture and what you need afterward. For an automated UI test, use XCTest’s XCUIScreen, XCUIElement, and XCUIScreenshotProviding. For a screenshot that a person takes and that should include high-fidelity, full-page content, use UIKit’s UIScreenshotService to provide PDF data. For a manual Simulator image, use Device Hub or simctl. These are separate workflows, not interchangeable versions of one in-app screenshot function.

Choose the Swift screenshot workflow first

Goal Capture is initiated by Use Typical output Runs in
Verify an app state in automated tests Test code XCUIScreen, app/window or element screenshot APIs Image and PNG data attached to test results XCTest/XCUIAutomation UI-test target
Add complete document content to a user screenshot The person using iOS or iPadOS UIScreenshotService plus a delegate PDF data associated with the scene’s windows Your app’s scene delegate and UIKit
Save a screen from Simulator or a connected device Developer or Xcode tooling Device Hub or xcrun simctl io PNG (or the format supported by the installed tool) Mac, Xcode and Simulator/device

Do not present UIScreenshotService as a general-purpose API for silently taking arbitrary screenshots. Apple documents it as a service invoked after a user requests a screenshot; your app supplies PDF data for its windows.

Take a screen or element screenshot in an XCUITest

Put this code in a UI-testing target, not in production application code. Launch and navigate before calling screenshot(); the API records the visual state that exists at that instant.

Capture the main display

import XCTest

final class CheckoutUITests: XCTestCase {
    func testCheckoutScreen() {
        let app = XCUIApplication()
        app.launch()

        // Navigate to the state you want to verify here.
        let screenShot = XCUIScreen.main.screenshot()
        let attachment = XCTAttachment(screenshot: screenShot)
        attachment.name = "Checkout screen"
        attachment.lifetime = .keepAlways
        add(attachment)
    }
}

XCUIScreenshot exposes an image representation and PNG image data. An XCTAttachment keeps the capture with the test or activity record, which makes failures and visual checkpoints reviewable in Xcode’s test reports.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Capture an app window

let app = XCUIApplication()
app.launch()

let windowScreenshot = app.windows.firstMatch.screenshot()
let attachment = XCTAttachment(screenshot: windowScreenshot)
attachment.name = "First app window"
attachment.lifetime = .keepAlways
add(attachment)

Use an explicit window or element when the test has multiple surfaces. Wait for the relevant element to exist and for asynchronous content to settle before capturing; otherwise a valid screenshot can still show a loading state.

Capture one UI element

let app = XCUIApplication()
app.launch()

let payButton = app.buttons["Pay"]
XCTAssertTrue(payButton.waitForExistence(timeout: 10))
let buttonShot = payButton.screenshot()
let buttonAttachment = XCTAttachment(screenshot: buttonShot)
buttonAttachment.name = "Pay button"
buttonAttachment.lifetime = .keepAlways
add(buttonAttachment)

UI elements provide screenshots through the screenshot-providing protocol used by XCTest. This is useful for a card, button, chart, or other bounded control rather than the entire display.

Capture every active display

for (index, screen) in XCUIScreen.screens.enumerated() {
    let shot = screen.screenshot()
    let attachment = XCTAttachment(screenshot: shot)
    attachment.name = "Display (index)"
    attachment.lifetime = .keepAlways
    add(attachment)
}

Multiple-display behavior depends on the test environment. Name attachments so a report makes clear which display produced each image.

Provide PDF data for a user-requested full-page screenshot

UIScreenshotService belongs to a UIWindowScene. When a person captures a screenshot involving your app’s windows, UIKit calls a delegate to retrieve PDF data and then makes that data available to the user. The service does not grant an app permission to capture the screen whenever it wants.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Register a scene delegate

import UIKit

final class ScreenshotPDFProvider: NSObject, UIScreenshotServiceDelegate {
    func screenshotService(
        _ screenshotService: UIScreenshotService,
        generatePDFRepresentationWithCompletion completionHandler: @escaping (Data?, Int, CGRect) -> Void
    ) {
        // Build PDF data for the scene's relevant content.
        // Supply the data and associated values to completionHandler.
        completionHandler(nil, 0, .zero)
    }
}

final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    private var screenshotProvider: ScreenshotPDFProvider?

    func scene(_ scene: UIScene,
                willConnectTo session: UISceneSession,
                options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = scene as? UIWindowScene else { return }
        let provider = ScreenshotPDFProvider()
        screenshotProvider = provider       // retain it for the scene's lifetime
        windowScene.screenshotService?.delegate = provider
    }
}

The listing shows the association and callback shape documented by Apple; it deliberately does not claim that the placeholder generates a useful PDF. Replace the body with your document renderer, verify the exact callback declaration and concurrency annotations in the SDK used by your project, and pass the generated data, page count and content rectangle to the completion handler. Keep the delegate alive; assigning a temporary object can leave the service without a valid delegate.

What “full page” means here

Your delegate supplies a PDF representation for the scene’s content. It is not the same as asking XCTest for a long bitmap, and it does not automatically scroll a SwiftUI or UIKit view and stitch every cell. Your implementation must decide how the document is laid out and rendered into PDF.

Apple notes that, beginning with iOS 17 and iPadOS 17, users can share or save generated full-page screenshots as a PDF or image. Treat that as deployment-target-specific behavior and verify it against the current SDK and the OS versions you support.

Capture a Simulator screen from macOS

Using simctl

  1. Boot the desired Simulator and launch your app.
  2. Navigate to the exact state to capture.
  3. Run:
xcrun simctl io booted screenshot screenshot.png

The archived Simulator guide says the filename is optional. Because command options can change with Xcode, run xcrun simctl io help on the installed version when you need format, device-selection or piping details. In a script, target a specific device UDID rather than relying on whichever device happens to be booted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Using Device Hub

  1. Run the app on a simulated or physical device.
  2. Navigate to the screen.
  3. In Device Hub, click Screenshot.
  4. Find the saved image on the Mac desktop.

Apple states that Device Hub saves at the full resolution of the simulated or physical device, independent of the Mac display resolution. For visionOS Simulator, dimensions and aspect ratio can differ from physical hardware, so verify output size before using an image for store artwork or pixel comparisons.

Make captures deterministic

  • Stabilize state: wait for network-driven views, animations and skeleton loaders to finish.
  • Use accessibility identifiers: they are less fragile than localized labels for finding an element.
  • Control data: use fixtures or a test account so text, prices and images do not change between runs.
  • Record context: include device model, OS, orientation and appearance (light or dark) with artifacts.
  • Separate artifacts: retain failure screenshots always; keep routine checkpoints only as long as your CI storage policy allows.

Common errors and fixes

“Cannot find” or an empty element screenshot

The query may be wrong, the element may not yet exist, or it may be outside the current hierarchy. Assert waitForExistence(timeout:), inspect the accessibility tree, and capture after navigation has completed.

The screenshot shows a spinner or stale content

The call is immediate and reflects current state. Wait on a predicate such as an “Loaded” marker, disable test-only animations, or increase the synchronization timeout. A fixed sleep is less reliable than waiting for a UI condition.

Attachments are missing from test results

Create an XCTAttachment, set an appropriate lifetime such as .keepAlways for debugging, and add it to the test or activity. Confirm the test runner actually reaches the attachment code when a failure occurs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The PDF delegate is never called

Check that the delegate is assigned to the correct UIWindowScene service, that the provider is retained, and that the screenshot was initiated by the user. This service is not a background capture trigger.

simctl reports no booted device

Boot a Simulator first, or replace booted with the target device’s UDID. Then run xcrun simctl io help to confirm syntax for your Xcode release.

Dimensions do not match a physical device

Simulator and hardware can differ, especially for visionOS. Inspect the actual pixel dimensions and crop or resize to the specification instead of assuming a matching aspect ratio.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If the thing you need is a hosted website image or PDF rather than your app’s XCTest artifact, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the ScreenshotNeo API documentation for authentication and options. The same endpoint can capture full pages, a CSS-selected element, dark mode or any viewport, retina output, PDFs with paper size/margins/orientation/page ranges, HTML/CSS, custom JavaScript, clicks, selector waits, network-idle waits, ad/tracker/request blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed image links, asynchronous webhooks, bulk requests for up to 100 URLs, usage data and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which helps when migrating.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

For Swift, call the endpoint with URLSession and write the returned bytes:

import Foundation

let endpoint = "https://api.screenshotneo.com/v1/shot"
var components = URLComponents(string: endpoint)!
components.queryItems = [
    URLQueryItem(name: "access_key", value: "YOUR_API_KEY"),
    URLQueryItem(name: "url", value: "https://stripe.com")
]

let task = URLSession.shared.dataTask(with: components.url!) { data, response, error in
    guard let data, error == nil else {
        print("Screenshot request failed:", error ?? URLError(.badServerResponse))
        return
    }
    do {
        try data.write(to: URL(fileURLWithPath: "shot.webp"))
    } catch {
        print("Could not save image:", error)
    }
}
task.resume()

Python and Node.js equivalents:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Free usage is 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000; every feature is included on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to begin.

Cost, reliability and pipeline notes

For XCTest, the main costs are simulator or device runtime and CI storage; keep image dimensions and attachment retention appropriate for your build volume. For simctl, make device selection explicit in CI and verify the file exists before uploading it. For UIScreenshotService, complete PDF generation promptly and handle failure by returning no data rather than blocking the user’s screenshot flow. For hosted captures, use waits and blocking rules deliberately, choose a cache TTL when repeatability matters, and inspect verdict and billing headers so your accounting distinguishes clean captures from failed or cached responses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can a production Swift app call XCUIScreen.main.screenshot()?

No. XCUIScreen is part of XCTest/XCUIAutomation for UI testing. Use UIKit rendering or the user-driven UIScreenshotService design for production features.

Does UIScreenshotService automatically make a scrollable SwiftUI view into a PDF?

No. Its delegate supplies PDF data for the scene. Your implementation must render the document content and define its layout.

Which method is best for App Store screenshots?

Use Device Hub or simctl for reproducible device captures, then verify dimensions for the target device and OS. visionOS Simulator output may not match physical hardware.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.