A multiplatform Apple app for experimenting with on-device AI language models. Built with SwiftUI and SwiftData, targeting iOS, macOS, and visionOS from a single codebase.
| Platform | Minimum Version |
|---|---|
| iOS / iPadOS | 26.5 |
| macOS | 26.3 |
| visionOS (xrOS) | supported |
Device families: iPhone, iPad, Apple Vision Pro (TARGETED_DEVICE_FAMILY = 1,2,7).
Core AI Language Model Test/
├── Core AI Language Model Test/ # App target source
│ ├── Core_AI_Language_Model_TestApp.swift # @main entry, SwiftData ModelContainer setup
│ ├── ContentView.swift # SwiftData item list with platform-adaptive navigation
│ ├── Item.swift # SwiftData @Model (timestamped item)
│ ├── LanguageModelDemo/ # Foundation Models framework demos
│ │ ├── RootTabView.swift # Tab navigation (Chat / Guided / Items)
│ │ ├── ChatDemoView.swift # Streaming chat with the on-device model
│ │ └── GuidedGenerationDemoView.swift # Structured output via @Generable
│ ├── Info.plist # Background modes (remote notifications)
│ ├── Core_AI_Language_Model_Test.entitlements # CloudKit, push notifications
│ └── Assets.xcassets/ # App icon, accent color
├── Core AI Language Model TestTests/ # Unit tests (Swift Testing framework)
├── Core AI Language Model TestUITests/ # UI tests (XCTest)
└── Core AI Language Model Test.xcodeproj/ # Xcode project
The app showcases Apple's on-device Foundation Models framework:
-
Reference: Adding intelligent app features with generative models
-
Chat (
ChatDemoView) — streaming conversation withLanguageModelSession.streamResponse(to:), session prewarming, availability handling (Apple Intelligence eligibility, model download state), and session reset. -
Guided Generation (
GuidedGenerationDemoView) — structured output using@Generable/@Guide: the model fills a typedTripPlanstruct (title, destination, days, activities) streamed asPartiallyGeneratedsnapshots.
Both demos degrade gracefully when the model is unavailable. Running them requires a device/OS with Apple Intelligence enabled.
- UI: SwiftUI.
RootTabViewhosts three tabs: the two language-model demos and the SwiftData item list.ContentViewrenders aListof items; aNavigationViewWrapperadapts navigation per platform (NavigationSplitViewon macOS, plain content elsewhere). Platform-specific toolbar items via#if os(...)conditionals. - AI: FoundationModels.
SystemLanguageModel.defaultwith availability checks;LanguageModelSessionfor streaming chat and guided generation of@Generabletypes. - Persistence: SwiftData.
Itemis the single@Model; the app configures a sharedModelContainerat launch (persistent, not in-memory). - Capabilities: CloudKit (iCloud services) and remote push notifications (
aps-environment: development,remote-notificationbackground mode) — groundwork for cloud sync.
| Target | Purpose |
|---|---|
Core AI Language Model Test |
Main app |
Core AI Language Model TestTests |
Unit tests — uses the Swift Testing framework (@Test, #expect) |
Core AI Language Model TestUITests |
UI tests — uses XCTest |
Single shared scheme: Core AI Language Model Test.
Requires Xcode with the appropriate platform SDKs.
# Build for macOS
xcodebuild -project "Core AI Language Model Test.xcodeproj" \
-scheme "Core AI Language Model Test" \
-destination "platform=macOS" build
# Build for iOS Simulator
xcodebuild -project "Core AI Language Model Test.xcodeproj" \
-scheme "Core AI Language Model Test" \
-destination "generic/platform=iOS Simulator" build
# Run tests
xcodebuild -project "Core AI Language Model Test.xcodeproj" \
-scheme "Core AI Language Model Test" \
-destination "platform=macOS" testOr open the project in Xcode and press ⌘R.
- Bundle identifier:
private.Core-AI-Language-Model-Test - Swift language version: 5.0 (Xcode toolchain)
- The Items tab retains the SwiftData starter template — a timestamped item list with add/delete — alongside the Foundation Models demos.