Logo for tanaschita.com

How to automate taking screenshots with fastlane for iOS

Learn how to setup fastlane's snapshot action.

24 Jul 2023 · 2 min read

As mentioned in this fastlane guide for iOS, fastlane provides a snapshot action to automatically generate screenshots for an iOS application.

Automatically taking screenshots of a mobile application can serve us developers in different ways, for example as part of publishing the app to the App Store, as part of a QA process or as part of UI testing to identify changes to previous versions.

Let's look at how we can use fastlane's snapshot action to do that.

Sponsorship logo
Architecture & Design Patterns for iOS
This book is a practical guide to essential architectural principles and design patterns for iOS development. It covers strategies for building maintainable apps with Swift and SwiftUI, including dependency injection, navigation, common patterns, and modularization.
LEARN MORE

The snapshot action uses the capabilities of UI tests to create the desired application state. If you never worked with UI tests before, check out this article on getting started with UI tests to learn more.

To setup snapshot, the following steps are required:

  1. Creating a new UI test target
  2. Running fastlane snapshot init in the project folder which will create a Snapfile and ./SnapshotHelper.swift
  3. Open the created Snapfile file to configure languages, devices and more, for example:
devices([
"iPhone 14"
])
output_directory("./screenshots")
clear_previous_screenshots(true)
override_status_bar(true)
  1. Add the created ./SnapshotHelper.swift file to the UI Test target
  2. Add a new Xcode scheme for the created UI Test target, open its Build section and enable the Run and Shared checkbox.
  3. Add the following code in the setUp() method:
let app = XCUIApplication()
setupSnapshot(app)
app.launch()
  1. Add interactions to the UI test class that lead to desired screens and call snapshot("NameOfTheScreen") to take a screenshot where needed.
  2. Run fastlane snapshot in the terminal. It will create the screenshots inside the fastlane/screenshots directory.

To add device frames around created screenshots, we can use the fastlane frameit action. We also have the possibility to add a background and titles by setting up a Framefile.json.

Sponsorship logo
Preparing for a technical iOS job interview
Preparing for a technical iOS Job Interview with over 300 questions & answers. Covering Swift & Objective-C, SwiftUI & UIKit, Combine, HTTP Networking, iOS File System, Core Data, Concurrency with async/await, Security, Automated Testing, Dependency Management, AI & Machine Learning and more.
LEARN MORE
Sponsorship logo
Architecture & Design Patterns for iOS
This book is a practical guide to essential architectural principles and design patterns for iOS development. It covers strategies for building maintainable apps with Swift and SwiftUI, including dependency injection, navigation, common patterns, and modularization.
LEARN MORE
Sponsorship logo
Become a sponsor of tanaschita.com
By publishing an article on different iOS topics every week, tanaschita.com is constantly growing in the developer community and may provide a great audience for you as a sponsor.
CLICK TO LEARN MORE

Newsletter

Image of a reading marmot
Subscribe

Like to support my work?

Say hi

Related tags

Articles with related topics

app distribution

continuous integration

ios

Understanding code signing and provisioning in iOS

Learn how certificates, App IDs, entitlements, and provisioning profiles work together.

24 Jul 2026 · 8 min read

Latest articles and tips

© 2026 tanaschita.com

Privacy policy

Impressum