What problem does it solve?
This Skill provides a complete reference to Apple's Foundation Models framework, clarifying its unique APIs, capabilities, and best practices. It helps developers implement on-device AI features, understand structured output, integrate tools, and manage streaming effectively.
Core Features & Use Cases
- Complete API Reference: Detailed guide covering
LanguageModelSession, @Generable, @Guide, Tool protocol, streaming, and dynamic schemas with all WWDC 2025 code examples.
- Performance & Error Handling: Strategies for prewarming sessions, managing context window limits, and handling generation errors like
exceededContextWindowSize and guardrailViolation.
- Tool Protocol Integration: Explains how to enable the model to autonomously execute custom code for external data (e.g., WeatherKit, MapKit, Contacts).
- Use Case: When you need to implement structured output from the on-device model, use this skill to understand how the
@Generable macro works with constrained decoding to guarantee type-safe Swift objects.
Quick Start
To create a basic LanguageModelSession, import FoundationModels and initialize with let session = LanguageModelSession().