On-Device AI with Swift
Building Production Features with Apple's Foundation Models Framework
-
- $39.99
-
- $39.99
Publisher Description
Build real Apple Intelligence features in Swift — private, offline, and free to run.
Apple's Foundation Models framework puts a ~3-billion-parameter language model on every Apple Intelligence device, with no server, no per-request cost, and no data leaving the device. This book shows you how to turn it into features your users can rely on, from the first prompt to a profiled, tested, production-ready app.
Every technical statement in this book was checked against Apple's own documentation and WWDC sessions, and every code example compiles against the iOS 26 SDK. Concepts are explained in connected prose, walked through line by line, and illustrated with 27 diagrams.
You will learn how to check availability and design fallbacks; keep user input out of instructions; generate typed Swift values with @Generable; stream results into SwiftUI; build tools; tune sampling and temperature; manage the 4,096-token context window; handle guardrails, refusals, and errors; cut latency with prewarming and measure it in Instruments; decide when to train a custom adapter; and evaluate features with quality and safety datasets.
The final chapter builds a complete SwiftUI travel-journal assistant end to end, combining every technique in the book.
Written for iOS and macOS developers who know Swift and SwiftUI and want to ship on-device AI features that are fast, private, and safe.