AIToday
Large Language ModelsAI Coding AssistantsITmedia AI+Published: Dec 3, 2026, 06:01 JST

Foundation Models framework brings on-device AI to Swift apps

Send on LINE
Foundation Models framework brings on-device AI to Swift apps

3 Key Points

  1. What happened

    A tutorial shows how importing Foundation Models framework, creating a LanguageModelSession with instructions, and calling try await session.respond(to:) adds AI text generation to a Swift app.

  2. Why it matters

    Developers can offer text generation inside an app without separately preparing an external AI service, since the model runs on the device and the sample uses a few lines of Swift code.

Ask AI

Ask the AI about this article. Questions and answers are published on this page

Context & Analysis

The tutorial is the first in a series aimed at readers who already know basic SwiftUI, and it lays out three ways to use Apple Intelligence from Swift: Foundation Models for text generation and reasoning, App Intents for letting Siri and other OS features operate an app, and Image Playground for image generation. The sample code focuses on the first and third because they are easier to demonstrate. For text generation, the flow is to import Foundation Models, create a LanguageModelSession with instructions that describe how the AI should respond, and then call respond(to:) with a prompt; the answer arrives in response.content. The tutorial notes that respond(to:) is asynchronous and can fail, so it is called with try await and errors are caught.

The image sample instead calls the system-provided generation screen via the imagePlaygroundSheet modifier, passing a concept string such as "a cat flying in space." It also checks supportsImagePlayground from the environment to decide whether the device supports the feature. The tutorial advises running samples on a real device, since simulator capabilities and execution conditions may differ. It distinguishes this on-device approach from conventional generative AI services that send input over the internet to an external server, noting benefits for privacy and for use in poor network conditions, while cautioning that not all Apple Intelligence processing is completed on the device.

FAQ
What does the Foundation Models framework let developers do?
It lets Swift apps use Apple's language model for tasks like answering questions, summarizing text, and understanding text or images. Developers pass a prompt and receive generated results through a LanguageModelSession.
Do I need an internet connection to use the on-device AI?
The on-device model processes requests inside the device without sending input to an external AI server. As a result, an internet connection is not required for those AI requests.
Does all Apple Intelligence processing stay on the device?
No. More advanced processing may use Private Cloud Compute (PCC), Apple's cloud infrastructure, and some features can also integrate with ChatGPT.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

By signing up you agree to the Terms of Service and Privacy Policy.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Related Articles

Next articleGoogle launches Gemini 4 Live audio models with 0.39-second responses