Dice Foundry Student Workbook

About This Course

Dice Foundry is a self-paced course for an experienced IT professional who is new to Swift. Over fourteen chapters you build one real iPhone app, a dice roller named Dice Foundry, by typing the code yourself in Xcode. You choose a die (D4 through D20), set a quantity and a modifier, roll, read the result in standard dice notation such as 3D6 + 2, and keep a saved history of past rolls. The app is small on purpose. Every part of it exists to teach something you will meet again in other iPhone apps.

The goal is not a finished app. The goal is that you can read Swift and SwiftUI, including code an AI assistant wrote for you; make small changes on your own; troubleshoot with a method instead of guesswork; recognize overcomplicated code; and direct an AI assistant with precise instructions. The measure of success is whether you understand how and why the app works and can apply that to your own projects.

Who this course is for

You know file systems, the command line, networking, debugging and automation. You may already have shipped apps with AI-assisted coding. You do not need any knowledge of Swift, SwiftUI, object-oriented programming or the way an iPhone app starts and runs. The course assumes none of that and introduces one major idea at a time. Where an analogy to infrastructure work genuinely helps (a monitored configuration value, a declarative manifest, serializing configuration to disk), the text uses it, marked as an Infrastructure Analogy. Where an analogy would confuse, it is left out.

What you get

The course is a set of documents that work together.

Document What it is for
Student Workbook (this document) Fourteen chapters of explanation and step-by-step implementation, plus the glossary, milestone source listings and a guide to the reference folders.
Exercises and Independent Challenges Each chapter's challenge restated, with three progressive hints, plus extra practice exercises. No answers.
Exercise Solutions and Answer Key Knowledge Check answers, complete challenge solutions with explanations, answers to the extra exercises, and the Chapter 14 final project solution.
Swift and SwiftUI Quick Reference Guide A compact reference to the language and framework features the course uses, to keep open beside Xcode.
Reading and Troubleshooting AI-Generated Swift Code A guide to reviewing and correcting Swift that an AI assistant produced.
Reference Checkpoints folder The Swift source files of the app as it should look at the end of each chapter, for comparison.

How each chapter teaches

Every chapter follows the same structure: Learning Objectives, Concept Explanation, Syntax Breakdown, Guided Implementation, Expected Results, Reading This Like a Developer, Troubleshooting, Knowledge Check, Independent Challenge, Chapter Completion Checklist, Development Checkpoint, and Prediction Answers. You are told what you will learn, you meet the idea in plain English, you see the syntax taken apart token by token, you type the code one small step at a time with an explanation of what each change does and why, and you finish by saving your work and comparing it with the reference.

The "Reading This Like a Developer" sections are a thread running through the whole course. In each one you trace where execution begins, which code runs when a button is pressed, which variables hold state, where a value comes from and where it changes, how the interface responds, where data is saved and how errors are handled. That is the skill that lets you open an unfamiliar Swift file and understand it.

What was and was not verified

The author compiled every reference checkpoint with Xcode 27.2 and recorded 0 errors and 0 warnings, and ran the unit tests in Chapters 12 and 13 and the final project on two simulators. The screenshots in the chapters are real captures from the iOS Simulator. The author did not run the app on a physical iPhone and did not test VoiceOver by ear or every Dynamic Type size. Where the course describes those, it says you should see a result and tells you how to check it yourself. See "Toolchain and Setup" for details.

How to Use This Workbook

This chapter explains how to work through the course so that you learn from it rather than copy from it.

The working method

  1. Read the chapter section by section, in order. Concepts are introduced before they are needed. A chapter may preview a later idea with a one-line explanation and a pointer forward; you are not expected to master it yet.
  2. Type the code yourself. Do not paste. Typing makes you notice every token, and the Syntax Breakdown sections tell you what each one means. Each change in the Guided Implementation is introduced by a Code Change callout that names the file, where in the file the change goes, and whether you add, replace, delete, move or create.
  3. Run often. The text tells you when to build with ⌘B, run with ⌘R and check the preview canvas, and what you should see. If what you see differs, stop and fix it before you continue. Errors compound.
  4. Answer the Predict callouts before you read on. Write your prediction down. The answers are in the Prediction Answers section at the end of the chapter.
  5. Take the Knowledge Check without looking back. The questions have no answers in the chapter. The answers are in the Exercise Solutions and Answer Key.
  6. Do the Independent Challenge on a Git branch, and return to the main line before the next chapter (see "Challenges and branches" below).
  7. Finish with the Development Checkpoint: commit, tag, and compare your project with the reference.

Your project folder

In Chapter 1 you create a project named DiceFoundry in a folder you choose, with Xcode's option to create a Git repository left on. Choose a folder once and keep it there. The Development Checkpoint commands in each chapter assume a stable location.

You work in a single project for the whole course. Each chapter changes the same project, starting from where the previous chapter ended. You do not start a new project for each chapter.

The reference checkpoints

For every chapter from 1 to 13 there is a folder in Reference-Checkpoints that shows the app as it should be at the end of that chapter. Chapter 14 is an independent project; its finished solution is in 03-Solutions-and-Answer-Key/Final-Project-Solution.

Chapter Reference folder
1 Checkpoint-01-Getting-Started
2 Checkpoint-02-Swift-Fundamentals
3 Checkpoint-03-Static-Interface
4 Checkpoint-04-State-and-Random
5 Checkpoint-05-Dice-Selection
6 Checkpoint-06-Multiple-Dice
7 Checkpoint-07-Modifiers-and-Notation
8 Checkpoint-08-Roll-History
9 Checkpoint-09-Persistence
10 Checkpoint-10-Reusable-Components
11 Checkpoint-11-Styling-Animation-Accessibility
12 Checkpoint-12-Debugging-and-Testing
13 Checkpoint-13-Architecture
14 none (solution in 03-Solutions-and-Answer-Key/Final-Project-Solution)

What a checkpoint contains, and what it does not

Important: Checkpoints are source files, not Xcode projects

A reference checkpoint is a folder of Swift source files. It does not contain an Xcode project (there is no .xcodeproj file), so there is nothing to double-click and open. The same is true of the Final Project Solution. You use a checkpoint by comparing it with your own project, or by copying its files into a project of your own, as described below.

Each checkpoint folder contains a DiceFoundry folder with the app's Swift source files. Checkpoints 12 and 13 and the Final Project Solution also contain a DiceFoundryTests folder with the unit tests. Checkpoints 11, 12 and 13 and the Final Project Solution also contain the asset catalog (Assets.xcassets), because Chapter 11 adds your own colors and the app icon; checkpoints 1 to 10 do not contain an asset catalog because the project template's default one is unchanged until Chapter 11. A checkpoint also never contains the project settings (minimum iOS version, display name, build settings). Those live in the project file that Xcode creates, which is why you set them yourself in Chapter 1.

The author's verification script generates a temporary project from each checkpoint with a command-line tool so that it can compile them automatically. That tool is not part of the course and you do not need it.

Comparing your work with a checkpoint (the normal use)

At the end of each chapter, compare your project's source files with the matching checkpoint. Two ways work:

  • FileMerge. In Xcode, choose Xcode → Open Developer Tool → FileMerge and compare your file with the file of the same name in the checkpoint's DiceFoundry folder. Chapter 3 shows this.
  • Terminal. Use diff on a file, or diff -r on a folder, as shown in each chapter's Development Checkpoint. Run it from a folder where both paths are valid, and replace the example paths with your own.

Differences in files that Xcode generates, in the project file and in whitespace are normal. Differences in the Swift files' code are what to investigate.

Catching up from a checkpoint

If your project has drifted from the course and you cannot find the cause, reset it to a checkpoint. Do this on a Git branch, or commit first, so you can undo it.

Warning: Not tested by the course author

The steps below use ordinary Finder and Xcode actions that the chapters describe (creating a project, folders that mirror the disk, target membership, adding a test target). The course author did not perform this exact copy procedure inside Xcode and did not check how every Xcode version reacts to files copied in from Finder. Menu and dialog wording may differ in your version. If something does not appear as described, use the fallback given.

To reset your project's source files to checkpoint N (your project already exists and has the right settings):

  1. Commit your current work in Git so you can return to it, or create a branch.
  2. Quit Xcode.
  3. In Finder, open the checkpoint's DiceFoundry folder and the DiceFoundry source folder inside your own project folder (the one that contains ContentView.swift).
  4. Copy the checkpoint's files and folders over the ones in your project folder, replacing files of the same name. Delete any file in your project that does not exist in the checkpoint, and that you do not want (for example, the Chapter 2 practice file SwiftPractice.swift is only present in Checkpoint 02; later checkpoints omit it and you may keep or delete yours).
  5. Reopen your project in Xcode. Look in the Project navigator for the copied files. Whether they appear without further action depends on how Xcode created your project (Chapter 10 explains the two kinds of folder). If they do not appear, choose File → Add Files to "DiceFoundry"… (the exact wording may differ in your Xcode version), select the copied files, and keep Add to targets: DiceFoundry ticked. Press ⌘B to build.
  6. If a copied file does not appear, or the build says it cannot find a type that you copied, your project uses the older group style or the file is not in the app target. Drag the file from Finder into the matching folder in the Project navigator, then select it and check that Target Membership shows DiceFoundry checked (Chapter 10, Step 2, shows where).

To start a new project from checkpoint N (for example, you want to begin Chapter 9 without having done Chapters 1 to 8):

  1. Create a new project exactly as Chapter 1, Step 2 describes: product name DiceFoundry, interface SwiftUI, language Swift, storage None, no tests, Git repository on.
  2. Set Minimum Deployments to iOS 17.0 and Display Name to Dice Foundry, as in Chapter 1, Steps 6 and 7. Do not skip this; the later chapters depend on it.
  3. Quit Xcode, then copy the contents of the checkpoint's DiceFoundry folder over the DiceFoundry source folder in your new project, as in the previous procedure. For checkpoints 11, 12 and 13, this also replaces the template's Assets.xcassets with the checkpoint's, which contains the course's colors and the app icon.
  4. If the checkpoint is 12 or 13, the project also needs the test target. Reopen the project and follow Chapter 12, Step 15 to create a Unit Testing Bundle with the Testing System set to Swift Testing and Target to be Tested set to DiceFoundry. Delete the template's sample test file, then copy the files from the checkpoint's DiceFoundryTests folder into the project's DiceFoundryTests folder. Chapter 12 explains the target membership of test files.
  5. Press ⌘B to build, then ⌘R to run. Commit the result and tag it, so that it is your own starting point.

A project reconstructed this way matches the checkpoint's code, but it was created by your copy of Xcode, so project-level details can differ from the author's. That is the same position you are in when you work through the chapters.

Challenges and branches

Independent Challenges change your project. To keep the guided project identical to the reference, do each challenge on a Git branch and then return to the main line:

git switch -c challenge-NN
git switch main

Replace NN with the chapter number, for example challenge-05. The first command creates and switches to the branch; the second returns you to the main line when you are finished. The course assumes your main branch is called main. If git branch shows a different name, use that name instead.

When you are stuck

Work through this order before you look at a reference:

  1. Read the first error message in Xcode. Fix the first error first; later errors are often consequences of it.
  2. Re-read the step you just completed. Compare your code with the code block, character by character.
  3. Check the chapter's Troubleshooting section for the message you see.
  4. Compare your file with the checkpoint (see above).
  5. Use the hints in the Exercises document for a challenge; read the solution only after a genuine attempt.
  6. Use an AI tutor with the prompt in this workbook. It is designed to help you reason, not to hand you the answer.

Pace

The course has no time limit, and the author did not measure completion times. Chapters are long because they explain why, not just what. Stop at a Development Checkpoint, never in the middle of a chapter's implementation. A good rhythm is to finish one chapter's Guided Implementation in a sitting, and to do the Knowledge Check and challenge in another.

Toolchain and Setup

What the course was verified with

Item Value
Xcode 27.2 (build 27B52)
Swift compiler 6.4.2, with the project in Swift 5 language mode
macOS used for authoring macOS 26
Minimum iOS deployment target iOS 17.0
Simulators used for verification iPhone 15 (iOS 17.5) and iPhone 18 Pro (iOS 27.2)
Test framework Swift Testing
Third-party code None

The screenshots were taken on an iPhone 18 Pro Max simulator running iOS 27.2. You can use any recent iPhone simulator.

What you need

  • A Mac that can run Xcode 27.2, with Xcode installed.
  • An iOS Simulator runtime installed. Chapter 1, Step 1 shows where to check: Xcode → Settings, then the Platforms or Components section, depending on your version.
  • Git. Xcode can create the repository for you in Chapter 1, and the Terminal commands in the Development Checkpoint sections use the git command.
  • A free Apple ID is not needed for the Simulator. In Chapter 1 you set Team to None.

You do not need a paid developer account, a physical iPhone, or any third-party library.

Settings that matter

When Xcode creates a project from its iOS App template, it applies defaults that the course relies on:

  • Swift language mode 5. The project uses SWIFT_VERSION = 5.0, even though the compiler is Swift 6.4.2. The course's code compiles with no warnings in this mode.
  • Default actor isolation: MainActor for the app target. This means the app's code runs on the main thread by default. The course explains this only at an introductory level in Chapter 13.
  • Test target has no default isolation. The test suites in Chapters 12 and 13 are marked @MainActor. In Swift 5 mode that is not strictly required, but Swift 6 mode requires it, so the course keeps it and explains why in Chapter 12.
  • Newest iOS as the deployment target. New projects default to the newest iOS. In Chapter 1, Step 6 you change Minimum Deployments to iOS 17.0. Do this once and do not change it again. The course needs iOS 17 for @Observable, .sensoryFeedback and the two-parameter form of onChange.

The author also ran a pass of the reference code in Swift 6 language mode, and the course explains the difference where it matters. You do not need to switch language modes.

If your Xcode is a different version

New Xcode versions may rename menu items, change the template's code, change default build settings, or default to Swift 6 language mode. The rule throughout the course is: if a name differs slightly from the text, look for the closest match, and focus on what the step is trying to achieve. Where the course quotes an error message, it says the message will be "similar to" what you see, because exact compiler wording changes between versions.

Note: Playgrounds need Xcode 26 or later

Chapter 2 practices Swift in #Playground blocks, which need import Playgrounds and Xcode 26 or later. If your Xcode is older than 26, you can still practice the same Swift code in any other Swift environment, but the chapter's steps assume #Playground is available.

Optional device lessons

The chapters are done in the Simulator. Four optional lessons, after the main course, cover what needs an iPhone. Each one says which chapter it follows:

  • D1 — Run Dice Foundry on your iPhone (after Chapter 1). Needs an iPhone, a USB cable and an Apple ID.
  • D2 — Feel the haptics (after Chapter 11). Needs D1.
  • D3 — Accessibility on a physical iPhone (after Chapter 11). Needs D1.
  • D4 — Run the final project on your iPhone (after Chapter 14). Needs D1.

The author has not run any of them on hardware.

What was not verified

The author did not verify:

  • Running on a physical iPhone, including signing, Developer Mode, haptics and VoiceOver by ear. Optional Device Lessons D1 to D4 give the steps; the author has not run them on hardware.
  • Every Dynamic Type size.
  • The exact wording of every Xcode menu. The menu paths in the chapters are described from knowledge of Xcode and checked against the course's reference code, not against every Xcode release.

Where a chapter asks you to test one of these, you are the one doing the testing, and the text says so.

Before you start Chapter 1

  • Xcode 27.2 (or the closest version you have) opens without asking to install more components.
  • At least one iOS Simulator runtime is installed.
  • You have chosen a folder for the project and will not move it.
  • You have read "How to Use This Workbook".

Course Map

Dice Foundry is built in fourteen chapters. Each chapter adds one major idea to the same project. The table shows what each chapter builds, the main ideas it teaches, and the reference checkpoint you compare with at the end.

Ch Title What you build Main ideas Checkpoint
1 Hello, World A template project, changed to a dice icon and "Dice Foundry" Xcode layout, project and target, @main, App, WindowGroup, #Preview, build vs run, minimum iOS version, Git checkpoint 01
2 Swift Fundamentals A practice file of playgrounds (the app does not change) Statements and expressions, let and var, basic types, operators, string interpolation, optionals, scope 02
3 SwiftUI Fundamentals A static screen: title, die circle, caption, Roll button struct, protocol conformance, body, some View, declarative UI, stacks, modifiers and their order, trailing closures 03
4 State, Functions, and Random Numbers The button rolls a D6 and shows the number Functions, parameters, return values, closures, @State, private, Int.random(in:) 04
5 Enumerations and Dice Selection A grid of six dice buttons with a selected die enum, raw values, CaseIterable, Identifiable, ForEach, ternary operator, LazyVGrid 05
6 Arrays, Loops, and Multiple Dice A stepper for quantity and a row of result chips with a total Arrays, for … in, ranges, reduce, Stepper, $ (preview), ForEach over indexes 06
7 Conditional Logic and Modifiers A modifier control and a result in dice notation if and else, switch, Boolean logic, validation, abs, snapshots of what was rolled 07
8 Structures and Data Models A RollResult model and a roll history list Stored and computed properties, initializers, value types, UUID, Date, optional state, ScrollView, map and joined 08
9 Persistent Storage History that survives quitting the app Sandbox, Documents directory, JSON, Codable, throws, try, do and catch, static, .onAppear 09
10 Reusable Components and Code Organization The same app split into small views and folders Child views, @Binding, single source of truth, access control, closures as properties, files and folders 10
11 Styling, Animation, and Accessibility Colors, cards, animation, haptics, VoiceOver support, an app icon Asset catalog, Theme, extension, withAnimation, @Environment, @ScaledMetric, @AppStorage, accessibility labels 11
12 Debugging and Testing A testable DiceRoller and a unit test target Compiler, runtime and logic errors, breakpoints, po, Swift Testing, dependency injection of randomness 12
13 Architecture and the View Model A RollViewModel that holds state and logic MVVM, class vs struct, @Observable, private(set), dependency injection, recognizing ObservableObject 13
14 Final Project: Extending Dice Foundry You add features on your own Planning across layers, filter, $0, allSatisfy, Picker with optional tags solution only

The shape of the course

  • Chapters 1 to 4 (foundations). You get an app running, learn the language you need, and make a button change what is on screen.
  • Chapters 5 to 8 (the app grows). You model dice and rolls with real types, handle several dice and a modifier, and keep a history in memory.
  • Chapters 9 to 10 (data and structure). You save the history to a file and reorganize the code without changing what it does.
  • Chapters 11 to 13 (professional practice). You polish the interface and make it accessible, learn to debug and test, and separate the app's logic from its views.
  • Chapter 14 (on your own). You add a percentile die, a maximum and minimum indicator, and a history filter, using the same layers you have learned to read.

One roll, end to end

The worked example used throughout the course is the same roll every time: a D6, quantity 3, modifier +2, with dice showing 4, 2 and 6. The notation is 3D6 + 2, the individual dice are 4, 2, 6, the subtotal is 12 and the total is 14. By Chapter 13 you can trace this roll from the button press, through random number generation and calculation, into the history, to the saved file and back to the screen.

What each chapter assumes you have

Each chapter begins from the end of the previous one, so completing the chapters in order is the intended path. A concept is used only after the chapter that teaches it. If a chapter uses something earlier, it gives a one-line explanation and a pointer to the chapter that teaches it fully. If you skip ahead, reset your project to the previous checkpoint using "Catching up from a checkpoint" in "How to Use This Workbook".

Conventions Used in This Course

Callouts

Callouts are boxed notes with a label. The labels are:

Label Meaning
Code Change An instruction to edit your project: the file, where in it, and the action (Add, Replace, Delete, Create file, Move). Every code change in a Guided Implementation starts with one.
Note Extra information that is useful but not essential.
Tip A shortcut or habit that saves time.
Important Something that causes real trouble if you miss it.
Warning A risk of data loss, a broken build or a wrong result.
Infrastructure Analogy A comparison to systems administration or automation work.
Predict Before You Run A short code-tracing exercise. Write your answer before you run or read on. Answers are in the chapter's Prediction Answers section.
Reading This Like a Developer A short aside on how to read the code in front of you.
AI-Assisted Development How the topic shows up in AI-generated code, and how to direct an AI assistant.
Exercise A small practice task.
Challenge An independent challenge.

Code blocks

Kind of block What it is
Dice Foundry code Real project code. Every line matches the reference checkpoint for that chapter. Indentation matches the reference so that pasted or typed code lines up.
Example, not part of the Dice Foundry project Illustrative code: syntax demonstrations, playground practice, "before" versions, and intermediate versions that a later step replaces.
Broken code, for diagnosis practice Code that is deliberately wrong, so that you can practice finding the fault.
Plain text blocks Console output, error messages, file trees and ASCII diagrams.
Terminal blocks Commands you type in Terminal.

An intermediate version of some code that a later step in the same chapter replaces appears as an example block, introduced by a Code Change callout so that you still type it. The final version is shown as Dice Foundry code.

Screenshots, mockups and diagrams

Screenshots labeled "Actual iOS Simulator screenshot" are real captures of the reference code on an iPhone 18 Pro Max simulator running iOS 27.2. A drawing in a text block captioned "Illustrative mockup — not a screenshot" is a sketch, not a capture. Diagrams are either text drawings or images with captions.

Keyboard shortcuts

Shortcut Action
⌘R Run the app
⌘B Build
⌘. Stop the running app
⌘U Run tests
⌥⌘P Resume or refresh the preview
⌥⌘↩ Show or hide the preview canvas
⇧⌘K Clean the build folder
⌘/ Comment or uncomment the selected lines
⌃I Re-indent the selected lines
⇧⌘O Open Quickly: jump to a file or symbol by name
⌘0 Show or hide the navigator
⌥⌘0 Show or hide the inspector
⇧⌘Y Show or hide the debug area
⌘, Open Xcode settings

Names

Thing Value
Product name in Xcode DiceFoundry
Name shown under the Home Screen icon Dice Foundry
App struct DiceFoundryApp, in DiceFoundryApp.swift
Test target (Chapter 12) DiceFoundryTests
History file roll-history.json, in the app's Documents directory
Haptics preference key "hapticsEnabled"
Example organization identifier com.blackwellfoundry; use your own
Example bundle identifier com.blackwellfoundry.DiceFoundry

Because the bundle identifier includes your own organization identifier, any command in the course that contains com.blackwellfoundry.DiceFoundry needs your own identifier in its place.

Writing conventions

  • The text says "you" and uses American spelling.
  • Menu items and buttons are in bold, for example File → New → Project….
  • Code, file names and type names are in code font, for example ContentView.swift.
  • "A message similar to" means the wording of the message depends on your Xcode version. Look for the same meaning, not the same words.
  • "You should see" describes what the course expects. It does not mean that the author tested your device or your setup.
  • Notation such as 3D6 + 2 means three six-sided dice with a modifier of +2.

Using an AI Tutor Alongside the Course

An AI assistant can help you through the course, and the course is designed to teach you to direct one. The risk is that the assistant gives you the answer and you learn nothing. The prompt below sets the assistant up as a tutor that works within the course: it asks you questions, checks your reasoning, stays within the concepts you have learned, and does not hand over challenge solutions.

How to use the prompt

  1. Copy the whole prompt below into a new conversation with the AI assistant of your choice.
  2. Replace the three bracketed items: your current chapter number, your Xcode version, and the minimum iOS version (17.0 unless you changed it).
  3. Start a new conversation when you begin a new chapter, and update the chapter number. The assistant has no memory of your project, so paste the code or error you want help with each time.
  4. When you ask for help, paste the exact code (not a description of it) and the exact text of any error, and say what you expected and what happened.
Warning: Check what the assistant tells you

An AI assistant can be wrong about Swift, SwiftUI and Xcode, especially about menu names and newer APIs. Treat its answers as hypotheses. Verify them by building and running, by reading the chapter, and by comparing with the reference checkpoint. Do not paste secrets, keys or customer data into a conversation.

The prompt

You are a patient Swift and SwiftUI tutor for a student working through the
"Dice Foundry" course. The student is an experienced IT professional
(infrastructure, storage, networking, automation) who is new to Swift. They
are building an iPhone dice-rolling app by typing the code themselves.
Their goal is to read and understand Swift, make small changes on their own,
troubleshoot, and direct AI coding assistants well. Understanding matters more
than finishing quickly.

My setup:
- Current chapter: [CHAPTER NUMBER, 1 to 14]
- Xcode version: [for example 27.2]
- Minimum iOS deployment target: [17.0]
- Swift language mode: 5 (the Xcode template default)
- Test framework in use from Chapter 12: Swift Testing (import Testing, @Test, #expect)
- No third-party libraries.

How to teach me:
1. Explain in plain English first, then show the syntax. Break new syntax down
   token by token. Use an analogy to infrastructure or automation work only
   when it is accurate; do not force one.
2. Prefer questions to answers. When I am stuck, give a nudge first, then a
   more specific hint, and give the full answer only if I ask for it after
   trying. Ask me to predict what code will do before you tell me.
3. Stay within what the course has taught up to my current chapter. If the
   best answer needs a later concept, say so in one sentence, name the topic,
   and give the simplest answer that fits what I know. Do not introduce new
   frameworks, patterns or abstractions unless I ask.
4. Do not give me the solution to an Independent Challenge or an Exercise. Give
   progressive hints only. If I say I have already tried hard and want the
   solution, you may give it, with an explanation of why it works.
5. Teach me to read code: where execution begins, which code runs when a button
   is pressed, which values are state, where a value comes from and where it
   changes, how the interface updates, where data is saved, how errors are
   handled, and which code is business logic versus presentation.
6. When I paste an error, first help me read it: which line, what it says,
   and what the likely causes are. Tell me how to investigate. Then suggest the
   smallest fix. Remember that the first error is often the cause of later ones.
7. When I paste AI-generated code, review it with me: what it does, whether it
   is more complicated than the task needs, whether it uses newer APIs than
   my iOS 17.0 minimum allows, and what I should ask the assistant to change.

Accuracy and honesty rules:
- Do not invent Xcode menu names, build settings, API names or exact error
  wording. If you are not sure, say so and say "the message will be similar
  to". Tell me to check the official documentation for anything
  version-sensitive.
- Do not claim that code compiles or runs correctly unless I have shown you
  the result of building or running it. You cannot run my project.
- Make no claims about physical-device behavior (signing, haptics) unless I
  have told you I tested it.
- Prefer the smallest correct change. Do not rewrite my whole file when a
  few lines are wrong.
- Use modern Swift for iOS 17 and later: @Observable (not ObservableObject)
  for new view models, and SwiftUI rather than UIKit. If I show you older
  code that uses ObservableObject, @Published or @StateObject, explain how it
  relates to the modern form.

Format:
- Short paragraphs. Code in fenced blocks marked swift.
- When you show a change, name the file, say where it goes, and say whether it
  adds to or replaces existing code.
- End most answers with one question that checks my understanding.

Good ways to use the tutor

  • Ask it to quiz you on the Knowledge Check questions after you have answered them yourself.
  • Paste a compiler error and ask what it means before asking for a fix.
  • Paste a function from the course and ask it to explain each line, then check its explanation against the chapter.
  • Ask it to find the bug in code you wrote while attempting a challenge, and to tell you where to look rather than what to type.
  • After Chapter 4, take a short piece of AI-generated code from your own work and ask the tutor to explain what each part does, then compare with the chapter.

Poor ways to use the tutor

  • Pasting a whole challenge and asking for the solution.
  • Asking it to "make it work" without reading what it changes.
  • Accepting a menu path or an API name from it without checking it in Xcode or the documentation.
  • Using it to skip the Development Checkpoint comparison. The reference checkpoint is a more reliable check than an assistant's opinion.