On-device models with Foundation Models

Modern platform Mid-level Swift 6.2+ iOS 26+ Reviewed By Alok Singh

Pick the fix

You want to summarise notes on device, but some users' devices don't support Apple Intelligence. Best approach?

Options
Hint 1 of 1

Availability depends on more than the OS version.

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Check SystemLanguageModel.default.availability, use a LanguageModelSession when available, and hide or replace the feature otherwise

Correct. It works where supported and degrades gracefully.

Why not the others?
  • B Call the model and show a crash report if it fails. Users get errors instead of a fallback.
  • C Send the notes to a paid cloud API without telling users. It's a privacy problem and a different product decision.
  • D Require iOS 26 for the whole app. The OS version doesn't guarantee model availability.

30-second answer

The Foundation Models framework (iOS 26) gives access to the on-device model behind Apple Intelligence. Check SystemLanguageModel.default.availability first, because the device may not support it or the feature may be off. Create a LanguageModelSession with instructions, call respond(to:), or stream responses, and use @Generable types for structured output and tools for calling your own code.

Practise saying it · 45 s. No recording, just a timer

Explain how you use the on-device model.

Say your answer out loud, then check which of these points you covered:

  • Availability check
  • LanguageModelSession
  • @Generable output
  • Fallbacks

Deep dive

It runs on device, works offline and has no per-request cost.

Unavailable reasons are deviceNotEligible, appleIntelligenceNotEnabled and modelNotReady (still downloading); handle each.

The context window is limited: read contextSize and keep prompts and history short.

Apple updates the model with OS releases, so re-test prompts on each major version.

@Guide constrains generated fields.

Always provide a fallback when unavailable.

Structured summary Type-checked · Swift 6.4
import FoundationModels

@Generable
struct NoteSummary {
    @Guide(description: "One-sentence summary")
    var headline: String
    var actionItems: [String]
}

func summarize(_ text: String) async throws -> NoteSummary? {
    guard case .available = SystemLanguageModel.default.availability else { return nil }
    let session = LanguageModelSession(instructions: "Summarise notes briefly.")
    return try await session.respond(to: text, generating: NoteSummary.self).content
}

Common mistakes

  • Assuming every device supports it.
  • Parsing free text instead of using @Generable.

Senior take & follow-ups

Seniors check availability, use structured output and design fallbacks.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do you get structured output?

    Show hint

    A @Generable type passed as the response type.

  2. What if the model isn't available?

    Show hint

    Hide the feature or offer a non-AI path.

Suggest a fix if something here is wrong or out of date.