UI tests exercise an app through the same controls a person uses. Xcode's UI test recorder turns a short simulator interaction into Swift code for an XCUITest test, providing a starting point for a repeatable check of the app's behaviour.
Recording requires a runnable app and an XCTest UI testing target, with the app scheme and an iPhone simulator selected in Xcode. The recorder inserts actions at the cursor inside a UI test method; a unit test target cannot receive a UI recording.
Generated actions describe what was tapped, but do not establish whether the app reached the intended screen. An assertion supplies that check, while accessibility identifiers keep the queries independent of button labels that may change with wording or localization.
Steps to record an XCUITest UI test in Xcode:
- Open MyAppUITests.swift in the project's UI testing target.

- Add a blank testContinue method inside the MyAppUITests class.
@MainActor func testContinue() throws { }
The existing UI test source imports XCTest and declares MyAppUITests as an XCTestCase subclass. Other test methods can remain in the class.
- Place the insertion point on the empty line inside testContinue.
- Click the circular Record a UI Test control beside that line in the source editor gutter.

- Click Start Recording in the confirmation dialog.
Xcode builds and launches the app before recording interactions. The test source remains read-only until recording stops.
- Tap Continue in the simulator to display Welcome.
The pictured MyApp has a Continue button that reveals a Welcome message. A different app generates queries for its own controls. In Xcode 27, simulator windows belong to Device Hub.
- Click Xcode's Stop button after the interaction appears in the test method.

- Replace the recorded method body with a fresh app launch and the continueButton tap.
let app = XCUIApplication() app.launch() app.buttons["continueButton"].tap()
The recording produced app.activate() and a query ending in .firstMatch.tap(). Using app.launch() starts a fresh app instance for each run. The continueButton identifier belongs to the button in this app; without firstMatch, duplicate matches fail instead of silently choosing the first one.
Related: How to query UI elements in XCUITest - Add an assertion after the tap to wait for the Welcome message.
let welcome = app.staticTexts["welcomeMessage"] XCTAssertTrue(welcome.waitForExistence(timeout: 5))
The message has the accessibility identifier welcomeMessage. The assertion fails if that element does not appear within five seconds, so a successful tap alone cannot pass the test.
- Save MyAppUITests.swift with Command-S.
- Run the test with Command-U.
This is Xcode's Product > Test action and runs the tests included in the active scheme.
- Confirm that testContinue() has a green passed indicator in the Test navigator.
The Test navigator is available with Command-6. A pass means the replay found the button, tapped it, and found the welcome message before the assertion timed out.