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.
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:
import SwiftUI
import SwiftData
@main
struct DayOneApp: App {
var body: some Scene {
WindowGroup {
EntryListView()
}
.modelContainer(for: Entry.self)
}
}Step 2 — Add the three screens
- 1Delete the template
Item.swiftthat Xcode generated (right-click it in the file navigator ▸ Delete ▸ Move to Trash) — yourEntrymodel replaces it.ContentView.swiftis no longer used either onceEntryListViewis the root view, so you can delete it the same way. - 2Create
EntryListView.swiftfrom the generated list code (plus theString.firstLineextension). - 3Create
EntryEditorView.swiftfrom the editor code. - 4Generate
EntryDetailViewwith 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
- 1Press ⌘R. Add an entry with the "+" button; confirm it appears at the top of the list.
- 2Tap it to open the detail screen; tap Edit, change the text, save, and confirm the change sticks.
- 3Swipe to delete a row. Stop and relaunch the app — your entries should still be there (that's SwiftData persisting to disk).
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
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.