Exercise 1: Accessibility Identifiers & a Real UI Test for Adding a Task — Possible Solution ==================================================================================================== // In TaskListView's toolbar: .toolbar { Button("Add") { isShowingNewTask = true } .accessibilityIdentifier("addTaskButton") } // In NewTaskView's toolbar: .toolbar { Button("Save") { guard !title.isEmpty else { return } store.add(title: title, priority: priority) dismiss() } .accessibilityIdentifier("saveButton") } // Also worth adding, so the TextField itself can be found: TextField("Title", text: $title) .accessibilityIdentifier("newTaskTitleField") // The UI test: func testAddingANewTask() { let app = XCUIApplication() app.launch() app.buttons["addTaskButton"].tap() app.textFields["newTaskTitleField"].typeText("Water the garden") app.buttons["saveButton"].tap() XCTAssertTrue(app.staticTexts["Water the garden"].exists) } HOW IT WORKS: Each real interactive element the test needs to find and interact with - the "Add" button, the title text field, and the "Save" button - gets its own real, stable .accessibilityIdentifier(), exactly following the chapter's own established pattern. The test itself launches a fresh real instance of the app via XCUIApplication().launch(), then drives it through the exact same real sequence a user would follow: tap "Add" to open the sheet, type a title into the real text field, tap "Save" to submit it. The final assertion, XCTAssertTrue(app.staticTexts["Water the garden"].exists), confirms the new task's own title genuinely appears somewhere in the app's real UI afterward - proving the entire real flow (opening the sheet, entering text, saving, dismissing, and the task list actually updating) worked correctly end to end, not just that individual pieces of logic behaved correctly in isolation the way Chapter 6's own unit tests already confirmed separately. ANSWER: Adding real .accessibilityIdentifier() modifiers to the "Add" button, the title TextField, and the "Save" button, then writing a UI test that launches the app and drives it through the full add-task flow via those identifiers, correctly implements a real, working end-to-end UI test confirming the new task actually appears in the app afterward. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly adds real accessibility identifiers to every element the test needs to interact with, and writes a genuine end-to-end test exercising the real app UI, exactly matching the chapter's own established XCUITest pattern.