Foundation Models is a new Apple framework introduced in iOS 27 that gives developers on-device access to the same Apple Intelligence language model powering system features, enabling text generation, structured output, and tool-calling entirely on-device without a network connection.
• Run powerful LLM inference entirely on-device with no API keys, no network calls, and no per-request cost — privacy is guaranteed by design
• Generate structured, type-safe Swift values directly from the model using `@Generable` macros, eliminating fragile JSON parsing
• Integrate conversational sessions with tool-calling so the model can invoke your own Swift functions to retrieve live app data
Demonstrates using a Foundation Models session with a `@Generable` struct to ask the on-device LLM for a structured recipe suggestion, then displays the result in SwiftUI — no network required.
import SwiftUI
import FoundationModels
// 1. Define a structured output type the model will populate
@Generable
struct Recipe {
@Guide(description: "The name of the dish")
var name: String
@Guide(description: "A one-sentence description of the dish")
var description: String
@Guide(description: "List of main ingredients")
var ingredients: [String]
@Guide(description: "Estimated preparation time in minutes")
var prepTimeMinutes: Int
}
@MainActor
class RecipeViewModel: ObservableObject {
@Published var recipe: Recipe?
@Published var isLoading = false
@Published var errorMessage: String?
private let model = SystemLanguageModel.default
func suggestRecipe(for ingredient: String) async {
guard SystemLanguageModel.isAvailable else {
errorMessage = "Apple Intelligence is not available on this device."
return
}
isLoading = true
errorMessage = nil
let session = LanguageModelSession(model: model)
do {
let prompt = "Suggest a simple recipe that features \(ingredient) as the star ingredient."
let result: Recipe = try await session.respond(to: prompt, generating: Recipe.self)
recipe = result
} catch {
errorMessage = error.localizedDescription
}
isLoading = false
}
}
struct RecipeSuggesterView: View {
@StateObject private var viewModel = RecipeViewModel()
@State private var ingredient = "salmon"
var body: some View {
NavigationStack {
Form {
Section("Ingredient") {
TextField("Enter an ingredient", text: $ingredient)
}
Button("Suggest Recipe") {
Task { await viewModel.suggestRecipe(for: ingredient) }
}
.disabled(viewModel.isLoading)
if viewModel.isLoading {
ProgressView("Thinking on-device…")
}
if let recipe = viewModel.recipe {
Section(recipe.name) {
Text(recipe.description)
.foregroundStyle(.secondary)
Text("Prep time: \(recipe.prepTimeMinutes) min")
.font(.caption)
ForEach(recipe.ingredients, id: \.self) { item in
Label(item, systemImage: "fork.knife")
}
}
}
if let error = viewModel.errorMessage {
Text(error).foregroundStyle(.red)
}
}
.navigationTitle("Recipe Suggester")
}
}
}
#Preview {
RecipeSuggesterView()
}Visual Intelligence brings iOS 17's Visual Look Up capabilities to a new developer-facing API surface in iOS 27, letting apps pipe live camera frames or static images through on-device scene understanding to extract subjects, text, barcodes, and rich semantic labels without any cloud round-trip.
iOS 27 opens the Foundation Models framework to third-party LLM providers via a new public LanguageModel protocol, enabling anyone to integrate custom, server-based, or open-source models using the same Swift API as Apple's on-device system model.
App Schemas let developers describe their app's content and actions using pre-defined domain schemas (like the Calendar domain) so Siri can understand, search, and act on app data without custom NLP. Entities conforming to IndexedEntity are donated to Spotlight's semantic index, enabling natural-language queries over app content.
In-depth guide
iOS 27 On-Device AI & Apple Intelligence →• The model is a fixed on-device model; you cannot swap in third-party or cloud models via this API • `@Generable` requires the FoundationModels module and uses Swift macros — ensure macro permissions are granted in Xcode • Sessions are stateful but not persistent across app launches; you must re-seed context manually • Availability must be checked at runtime with `SystemLanguageModel.isAvailable` before calling any generation APIs • Structured generation may fail if the schema is too deeply nested or contains unsupported types
Requires an Apple Intelligence-capable device (iPhone 15 Pro or later, or M-series iPad/Mac). Not available in all regions. Simulator support is limited — a real device is needed for full inference.