A SwiftUI demo of Apple's on-device Foundation Models — streaming a structured to-do list from a natural-language prompt.
Foundation Models SwiftUI is a compact sample app that shows how to use Apple's on-device FoundationModels framework directly from SwiftUI. Tapping the Apple Intelligence toolbar button sends a text prompt to a LanguageModelSession, which generates a list of to-do items and streams them back into the UI as they are produced. The whole flow runs on device using Apple Intelligence — no server, network call, or API key required.
- 🧩 Structured generation — a
Todomodel annotated with@Generablelets the language model produce strongly-typed results instead of raw text. - 🔄 Streaming responses — uses
session.streamResponse(generating:)to update the list incrementally as each chunk arrives. - 📝 Prompt-driven to-do list — starts from an editable prompt (default: "Create a 10 item list") and renders the generated tasks in a SwiftUI
List. - 🍎 On-device Apple Intelligence — powered entirely by the
FoundationModelsframework; nothing leaves the device. - 🏗️ Clean MVVM structure — a
@MainActorObservableObjectview model drives an@ObservedObjectview, with async/await handling the generation loop.
git clone https://github.com/ahmetbostanciklioglu/FoundationModelsSwiftUI.git
cd FoundationModelsSwiftUI
open FoundationModelsApp.xcodeprojOpen the project in Xcode, select a Foundation Models capable target, and press ⌘R to build and run.
- iOS 26.1 or later (a device/simulator with Apple Intelligence and the Foundation Models framework)
- Xcode 26+
- Swift 5.0
Ahmet Bostancıklıoğlu — @ahmetbostanciklioglu · ahmetbostancikli@gmail.com
⭐ If this helped you, consider giving the repo a star!




