Back to course overview
Module 3Building the UI with SwiftUI + AI 30 min

Lab: Build your main screens

Assemble the list, editor, and detail screens into a working (AI-free) app you can click through in the simulator.

Outcome of this lab

A running app where you can create, read, edit, and delete entries — persisted with SwiftData. No AI features yet; that's Module 5. This is a complete, useful little app on its own.

Step 1 — Enable SwiftData storage

Open your app's entry point (e.g. DayOneApp.swift) and register the model container so every view can reach the store:

DayOneApp.swiftswift
import SwiftUI
import SwiftData

@main
struct DayOneApp: App {
    var body: some Scene {
        WindowGroup {
            EntryListView()
        }
        .modelContainer(for: Entry.self)
    }
}

Step 2 — Add the three screens

  1. 1Delete the template Item.swift that Xcode generated (right-click it in the file navigator ▸ DeleteMove to Trash) — your Entry model replaces it. ContentView.swift is no longer used either once EntryListView is the root view, so you can delete it the same way.
  2. 2Create EntryListView.swift from the generated list code (plus the String.firstLine extension).
  3. 3Create EntryEditorView.swift from the editor code.
  4. 4Generate EntryDetailView with a prompt: "Show the entry's body as read-only text, the date, and — if present — aiTitle, mood, and reflection. Add an Edit button in the toolbar that presents EntryEditorView with the existing entry."

Step 3 — Run and click through everything

  1. 1Press ⌘R. Add an entry with the "+" button; confirm it appears at the top of the list.
  2. 2Tap it to open the detail screen; tap Edit, change the text, save, and confirm the change sticks.
  3. 3Swipe to delete a row. Stop and relaunch the app — your entries should still be there (that's SwiftData persisting to disk).
When something's broken

If a screen is blank or a tap does nothing, don't regenerate everything. Read the Xcode console for red errors, and check that view names match exactly (Swift is case-sensitive). Paste the specific error to your assistant with the relevant file. Precision beats brute force.

Step 4 — Commit your working app

bashbash
git add .
git commit -m "Working CRUD app: list, editor, detail with SwiftData"

Take a second to appreciate this: you have a real, persistent iOS app you built by directing AI and reading its output. Next, you'll understand the storage you just used — then teach the app to talk to the internet, the foundation for the AI feature that makes it special.