The Do iOS 2026 lineup came back full of Foundation Models. The tutorials are easy to find as well: open a session, send a prompt, paste the string into a screenshot. I wanted the step after that. The feature has to survive a Tuesday, on a phone where the model is missing, still downloading, or simply slow.
The feature is small. The user writes a note. The app suggests a tag and a title. The user accepts the suggestion, edits it, or ignores it. The note is saved in every case.
The plain note field comes first. The suggestion is a layer I add only when the on-device model can run.
Apple ships a tagging use case for this shape of job. Availability belongs to that instance, so the view switches on it.
import SwiftUI
import FoundationModels
struct NoteEditor: View {
private var model = SystemLanguageModel(useCase: .contentTagging)
@State private var note = ""
@State private var title = ""
@State private var tag = ""
@State private var suggestion: NoteSuggestion?
var body: some View {
VStack(alignment: .leading, spacing: 12) {
TextField("Title", text: $title)
TextField("Note", text: $note, axis: .vertical)
.lineLimit(3...8)
if case .available = model.availability {
Button("Suggest a title") {
Task { suggestion = await suggestion(for: note) }
}
if let suggestion {
Button("\(suggestion.tag) · \(suggestion.title)") {
title = suggestion.title
tag = suggestion.tag
}
}
}
}
.padding()
}
}
.available is the only branch that adds controls. .deviceNotEligible and any other unavailable reason render the title and the note, and nothing else. .modelNotReady is the same screen while the model is still downloading. I read availability again when the scene becomes active, so a finished download shows up as the button, with no progress UI of its own.
A model can be available and still be the wrong language. When model.supportsLocale(.current) is false, I keep the same plain fields. I would rather show no suggestion than a tag in a language the model does not claim to speak.
The call returns a Swift value, so the chip can only show a tag from the list and a title I can check.
@Generable
struct NoteSuggestion {
@Guide(description: "Exactly one of: bug, meeting, recipe, complaint, other")
var tag: String
@Guide(description: "A title of at most 60 characters, using the user's words")
var title: String
}
enum NoteSuggestions {
static let instructions = """
Suggest one tag and a short title for the user's note.
The tag is exactly one of: bug, meeting, recipe, complaint, other.
The title is at most 60 characters and uses the user's words.
"""
}
func suggestion(for note: String) async -> NoteSuggestion? {
let trimmed = note.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return nil }
guard case .available = model.availability else { return nil }
guard model.supportsLocale(.current) else { return nil }
do {
let prompt = Prompt(trimmed)
let count = try await model.tokenCount(for: prompt)
// Instructions, the schema, and the reply share the window with the note.
guard count <= model.contextSize / 2 else { return nil }
let session = LanguageModelSession(
model: model,
instructions: NoteSuggestions.instructions
)
let response = try await session.respond(
to: trimmed,
generating: NoteSuggestion.self
)
return response.content
} catch {
return nil
}
}
The half-window check leaves room on purpose. A long pasted note keeps the user's text and skips the suggestion. A guardrail, a context error, a refusal: same result. The fields on screen already hold what the user typed.
Private Cloud Compute, the LanguageModel protocol, and dynamic profiles are the tools for a conversation that has to change models halfway through. That is the material in the Foundation Models workshops at Do iOS. This feature uses one model and stops.
Wording in the instructions will change. I want a number that moves when the wording gets better, and stays put when it only sounds better.
I keep about twenty notes with tags I assigned myself. A bug report, a meeting scrap, a recipe, a complaint, and at least one note that could honestly go either way. Four samples show the shape. The expected title is a word from the note. The test checks that the word survived. Asking for one exact sentence would score the model on luck.
import Evaluations
import Testing
struct TaggedNote: Codable, Sendable {
var tag: String
var title: String
}
struct SuggestionUnavailable: Error {}
struct NoteSuggestionEvaluation: Evaluation {
let tagMatch = Metric("TagMatch")
let titleFit = Metric("TitleFit")
let dataset = ArrayLoader(samples: [
ModelSample(
prompt: "The build failed on the archive step again.",
expected: TaggedNote(tag: "bug", title: "archive")
),
ModelSample(
prompt: "Thursday 10:00 with design, bring the new empty states.",
expected: TaggedNote(tag: "meeting", title: "design")
),
ModelSample(
prompt: "Pasta, chili, lemon. Ten minutes, maybe twelve.",
expected: TaggedNote(tag: "recipe", title: "pasta")
),
ModelSample(
prompt: "Dinner with the release crew after the archive finally worked.",
expected: TaggedNote(tag: "meeting", title: "dinner")
),
])
func subject(from sample: ModelSample<TaggedNote>) async throws -> ModelSubject<TaggedNote> {
guard let suggestion = await suggestion(for: sample.prompt) else {
throw SuggestionUnavailable()
}
return ModelSubject(
value: TaggedNote(tag: suggestion.tag, title: suggestion.title)
)
}
var evaluators: Evaluators {
Evaluator { sample, subject in
guard let expected = sample.expected else { return tagMatch.ignore() }
let allowed = ["bug", "meeting", "recipe", "complaint", "other"]
let matches = subject.value.tag == expected.tag
&& allowed.contains(subject.value.tag)
return matches ? tagMatch.passing() : tagMatch.failing()
}
Evaluator { sample, subject in
guard let expected = sample.expected else { return titleFit.ignore() }
let title = subject.value.title
let fits = title.count <= 60
&& title.localizedCaseInsensitiveContains(expected.title)
return fits ? titleFit.passing() : titleFit.failing()
}
}
func aggregateMetrics(using aggregator: inout MetricsAggregator) {
aggregator.computeMean(of: tagMatch)
aggregator.computeMean(of: titleFit)
}
}
struct NoteSuggestionTests {
static let evaluation = NoteSuggestionEvaluation()
@Test(.evaluates(Self.evaluation))
func suggestionQuality() async throws {
let result = EvaluationContext.current.result
#expect(result.aggregateValue(.mean(of: Self.evaluation.tagMatch)) > 0.8)
#expect(result.aggregateValue(.mean(of: Self.evaluation.titleFit)) > 0.8)
}
}
suggestion(for:) is the same function the button calls. The test and the screen cannot drift apart. The dinner note is the one I expect to open in the report. It can read as a meeting or as something else, and the per-sample row is where that shows up.
0.8 is the bar for showing the chip. The first run tells me whether the instructions clear it. When they miss, I change the instructions and run the same notes again. The two means, and the rows that failed, are the comparison.
I run this on a phone that supports Apple Intelligence. The on-device model is a device feature, and a simulator result would tell me about a machine my users are not holding.
When the scores are fine and the chip still arrives late, I open the Foundation Models instrument. It shows the session, the token counts, and the wait before the first token. Shorter instructions and a shorter title are the usual fix. The Evaluations framework is the score. Instruments is the pause.
The user confirms every write. Tapping the chip copies the tag and the title into the fields. Saving stays a separate action.
A person owns any safety decision. A wrong tag is a nuisance the user can see. A decision about whether the note is allowed to exist is a different job, and I want someone on that path who can be asked why.
This job stays on the device. Private Cloud Compute brings a larger context window and a reasoning pass, along with a network and an entitlement. A title and a tag from the user's own sentence need none of that. A train with no signal and a phone that cannot run Apple Intelligence already share one screen. I want this feature on that screen too.
In January I wrote about what seniority looks like when an assistant writes the code. This is the same job from the other side. The decision worth keeping is the boundary: which part of the screen the model may fill in, and which part has to stand on its own.
Build the screen that works with the model turned off. Measure the suggestion before you let it touch anything the user cannot undo.