---
title: 'XCUITest Tutorial: iOS UI Testing in Swift: Free Online Course'
description: 'Learn XCUITest from a first UI test target to a suite on real iPhones:
  element queries, waiting without sleeps, screen objects, launch arguments, build-for-testing
  and CI. Free, hands-on, Swift.'
source_url:
  html: https://testingbot.com/resources/courses/xcuitest
  md: https://testingbot.com/resources/courses/xcuitest.md
---

Course

[XCUITest Tutorial: iOS UI Testing in Swift](https://testingbot.com/resources/courses/xcuitest)

Chapter 1 of 11

1. [1 XCUITest Tutorial: iOS UI Test Automation in Swift](https://testingbot.com/resources/courses/xcuitest)
2. [2 Add a UI Test Target and Run Your First Test](https://testingbot.com/resources/courses/xcuitest/add-a-ui-test-target)
3. [3 Element Queries and Accessibility Identifiers](https://testingbot.com/resources/courses/xcuitest/queries-and-accessibility-identifiers)
4. [4 Interactions and Assertions](https://testingbot.com/resources/courses/xcuitest/interactions-and-assertions)
5. [5 Waiting Without sleep(): waitForExistence and Predicates](https://testingbot.com/resources/courses/xcuitest/waiting-without-sleep)
6. [6 Screen Objects in Swift](https://testingbot.com/resources/courses/xcuitest/screen-objects)
7. [7 Launch Arguments and Environment: Control App State](https://testingbot.com/resources/courses/xcuitest/launch-arguments-and-environment)
8. [8 Build for Testing: The App and the Test Runner](https://testingbot.com/resources/courses/xcuitest/build-for-testing)
9. [9 Run XCUITest on Real iPhones with TestingBot](https://testingbot.com/resources/courses/xcuitest/run-on-testingbot)
10. [10 XCUITest in CI with GitHub Actions](https://testingbot.com/resources/courses/xcuitest/ci-github-actions)
11. [11 XCUITest Knowledge Check](https://testingbot.com/resources/courses/xcuitest/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 1 of 11 Intermediate 6 min read 1 quick check Updated Nov 2026 

# XCUITest Tutorial: iOS UI Test Automation in Swift

Learn XCUITest from a first UI test target to a suite on real iPhones: element queries, waiting without sleeps, screen objects, launch arguments, build-for-testing and CI. Free, hands-on, Swift.

## What you will learn

1. XCUITest Tutorial: iOS UI Test Automation in Swift
2. [Add a UI Test Target and Run Your First Test](https://testingbot.com/resources/courses/xcuitest/add-a-ui-test-target)
3. [Element Queries and Accessibility Identifiers](https://testingbot.com/resources/courses/xcuitest/queries-and-accessibility-identifiers)
4. [Interactions and Assertions](https://testingbot.com/resources/courses/xcuitest/interactions-and-assertions)
5. [Waiting Without sleep(): waitForExistence and Predicates](https://testingbot.com/resources/courses/xcuitest/waiting-without-sleep)
6. [Screen Objects in Swift](https://testingbot.com/resources/courses/xcuitest/screen-objects)
7. [Launch Arguments and Environment: Control App State](https://testingbot.com/resources/courses/xcuitest/launch-arguments-and-environment)
8. [Build for Testing: The App and the Test Runner](https://testingbot.com/resources/courses/xcuitest/build-for-testing)
9. [Run XCUITest on Real iPhones with TestingBot](https://testingbot.com/resources/courses/xcuitest/run-on-testingbot)
10. [XCUITest in CI with GitHub Actions](https://testingbot.com/resources/courses/xcuitest/ci-github-actions)
11. [XCUITest Knowledge Check](https://testingbot.com/resources/courses/xcuitest/knowledge-check)

[Continue where you left off](https://testingbot.com#)

## TestingBot XCUITest Certification

Turn this course into a free, resume-worthy credential: pass the exam, run the course suite on TestingBot, and get a verifiable certificate for your LinkedIn profile.

[How it works](https://testingbot.com/resources/courses/xcuitest/certification)On this page
1. [How XCUITest sees your app](https://testingbot.com#how-xcuitest-sees-your-app)
2. [XCUITest, Appium, or something else?](https://testingbot.com#xcuitest-appium-or-something-else)
3. [What you will build](https://testingbot.com#what-you-will-build)
4. [Prerequisites](https://testingbot.com#prerequisites)

_Last reviewed November 2026 against Xcode 26.4.1 (iOS 26.4 simulator) and the TestingBot CLI (@testingbot/cli) 1.5.0._

XCUITest is Apple's UI testing framework for iOS, iPadOS, macOS and tvOS apps. It ships with Xcode as part of XCTest, the same framework that runs your unit tests, so there is nothing to install: you add a UI test target to your project, write tests in Swift, and run them with Cmd+U or `xcodebuild test`.

This course takes you from an empty UI test target to a suite that runs on real iPhones in the cloud and in CI. Here is the kind of test you will write by chapter 5:

```swift
func testSignInAndAddTwoTasks() throws {
    let list = LoginScreen(app: app)
        .signIn(email: "anna@example.com", password: "secret")

    list.add("Buy milk").add("Call Anna").toggle("Buy milk")

    XCTAssertEqual(list.rows.count, 2)
    XCTAssertEqual(list.openCount, "1 open")
}
```

It signs in, adds two tasks, ticks one off and checks the counter. Every test in this course ran on an iPhone 17 simulator with iOS 26.4, and the finished suite ran on real iPhones on TestingBot (chapter 8 has the session IDs).

## How XCUITest sees your app[#](https://testingbot.com#how-xcuitest-sees-your-app)

A UI test does not run inside your app. Xcode builds a second app, the **test runner** (`TasksUITests-Runner.app` in this course), installs both on the simulator or device, and the runner drives your app from the outside through the accessibility layer. Your test code talks to an `XCUIApplication` proxy: it can find elements, tap, type and swipe, and read what accessibility exposes (labels, values, identifiers, frames). It cannot call your app's functions or read its variables.

That is the main design decision behind everything in this course:

- **You find elements the way VoiceOver does** , by accessibility identifier, label or type. Chapter 2 is about making those stable.
- **You set app state through the front door** : launch arguments and environment variables the app reads at start-up (chapter 6), not by poking at singletons.
- **XCUITest waits for the app to be idle** before each action, which removes a lot of timing trouble, but not all of it. Network calls and system sheets still need explicit waits (chapter 4).

Unit tests (`@testable import`, calling code directly) live in a separate _unit test_ target. This course is only about the UI test target.

## XCUITest, Appium, or something else?[#](https://testingbot.com#xcuitest-appium-or-something-else)

There is no single right tool. The honest trade-offs:

| | XCUITest | Appium (XCUITest driver) | Maestro |
| --- | --- | --- | --- |
| Language | Swift (or Objective-C) | Any WebDriver client: Java, JavaScript, Python, ... | YAML, with JavaScript for logic |
| Platforms | Apple platforms only | iOS and Android, separate drivers | iOS and Android |
| Lives in | The app's Xcode project | A separate test project | A folder of flows |
| Speed and stability | Fast; runs next to the app with Apple's own idle detection | Extra hop through a WebDriver server on the device | Its own waiting and retries |
| Who usually writes it | iOS developers | QA engineers, cross-platform teams | QA engineers and developers |

Choose XCUITest when the people who build the iOS app also own its UI tests, when the tests should run on every pull request next to the unit tests, and when you want the fastest feedback Apple's tooling can give. Its limits are just as clear: it covers Apple platforms only, it needs a Mac and Xcode, and every change means a rebuild of the test bundle.

Appium's iOS driver is itself built on XCUITest (it drives the device through WebDriverAgent, an XCUITest-based server), so the two are not rivals so much as layers. Appium adds one API for iOS and Android and lets you write tests in any language. If that matters more than speed, the [Appium and WebdriverIO course](https://testingbot.com/resources/courses/appium-webdriverio) is the better start. For YAML flows that run on both platforms, see the [Maestro course](https://testingbot.com/resources/courses/maestro). The [Appium vs XCUITest comparison](https://testingbot.com/appium-vs-xcuitest) goes deeper on the choice, and the [Mobile App Testing course](https://testingbot.com/resources/courses/mobile-app-testing) covers the wider picture: simulators versus real devices, frameworks, device matrices.

A UI test needs the app's shopping basket to contain three items before it starts. Which approach fits how XCUITest works?

 Call `Basket.shared.add(...)` from the test, using `@testable import` Pass a launch argument or environment variable that the app reads at start-up to seed the basket Add `sleep(5)` so the basket has time to fill

UI tests run in a separate runner process and can only reach the app through accessibility and launch configuration. `@testable import` works in unit tests, where the code runs in the same process, but in a UI test the singleton you change is a copy in the runner, not the one in the app.

## What you will build[#](https://testingbot.com#what-you-will-build)

The course uses a small SwiftUI app called **Tasks** : a sign-in screen (the password is `secret`, and the "server" answers after two seconds) and a list where you add, tick off and delete tasks. It is under 200 lines of Swift; the chapters show the parts that matter for testing. You can follow along with the course's code or apply each chapter to your own app.

1. Add a UI test target and run your first test
2. Element queries and accessibility identifiers
3. Interactions and assertions
4. Waiting without `sleep()`
5. Screen objects in Swift
6. Launch arguments and environment variables
7. Build for testing: the two bundles a device needs
8. Run the suite on real iPhones on TestingBot
9. CI with GitHub Actions
10. Knowledge check

## Prerequisites[#](https://testingbot.com#prerequisites)

- A Mac with **Xcode** installed (`xcodebuild -version` should print a version) and at least one iOS simulator (`xcrun simctl list devices available`).
- Basic Swift: structs, closures, optionals. You do not need to know SwiftUI to follow the tests.
- For chapters 8 and 9: Node.js (for the TestingBot CLI) and a TestingBot account with access to real iOS devices.

The [TestingBot XCUITest documentation](https://testingbot.com/support/app-automate/xcuitest) is the reference for every cloud option; this course is the how-to that leads up to it.

[Next · Chapter 2 Add a UI Test Target and Run Your First Test](https://testingbot.com/resources/courses/xcuitest/add-a-ui-test-target)

On this page

1. [How XCUITest sees your app](https://testingbot.com#how-xcuitest-sees-your-app)
2. [XCUITest, Appium, or something else?](https://testingbot.com#xcuitest-appium-or-something-else)
3. [What you will build](https://testingbot.com#what-you-will-build)
4. [Prerequisites](https://testingbot.com#prerequisites)

Certification

Earn the free, resume-worthy TestingBot XCUITest Certification for this course.

[How it works](https://testingbot.com/resources/courses/xcuitest/certification)

## Other free courses

- [Mobile App Testing: From First Test to CI A free, hands-on mobile app testing course: emulators vs real devices, Appium vs Espresso vs XCUITest vs Ma...](https://testingbot.com/resources/courses/mobile-app-testing)
- [Accessibility Testing Tutorial: WCAG 2.2 A free, hands-on accessibility testing course: WCAG 2.2 in practice, manual keyboard and screen reader chec...](https://testingbot.com/resources/courses/accessibility-testing)
- [Selenium Locators and Locator Strategies A free course on Selenium locators and locator strategies: CSS selectors, XPath, role-based and test-id loc...](https://testingbot.com/resources/courses/locator-strategies)
- [Flaky Tests: Find, Fix and Prevent Fix flaky tests for good: measure them, then remove the four root causes (waits, shared data, test order, r...](https://testingbot.com/resources/courses/flaky-tests)

[Browse all courses](https://testingbot.com/resources/courses)
