ChatBot is a SwiftUI iOS app that uses Apple's Foundation Models for on-device conversations and SwiftData for local chat history.
Click the preview above to open the full demo video. It shows chatting, browsing previous sessions, and using image-based context in conversations.
- Text-based AI chat using
FoundationModels - Persistent chat sessions with
SwiftData - Previous chat list with session switching
- Image upload from the photo library
- Vision-powered image understanding before sending image context to the language model
- User-facing chat bubbles that show only the uploaded image and the user's typed message
The app does not send raw images directly into the language model response pipeline. Instead:
- The user selects an image from the photo library.
- Vision analyzes the image.
- OCR is extracted with
VNRecognizeTextRequest. - Visual labels are extracted with
VNClassifyImageRequest. - The extracted image context is kept hidden from the user-facing chat bubble.
- That hidden context is appended to the model prompt so the assistant can answer questions about the image.
This keeps the UI clean while still allowing the assistant to respond intelligently to uploaded images.
- SwiftUI
- Foundation Models
- Vision
- PhotosUI
- SwiftData
- The user starts a new chat or opens an existing conversation.
- Messages are processed with Apple's on-device foundation model support.
- Every conversation is saved locally with
SwiftData. - If the user attaches an image, Vision extracts useful context before the prompt is sent.
- The assistant replies using the typed message plus any hidden image context.
ChatBot/Views: UI screens and chat renderingChatBot/View Model: chat state and prompt orchestrationChatBot/Model: app-facing message and session models plus schema helpersChatBot/Model/Schema: SwiftData migration plan and current schema aliasesChatBot/Model/Schema/Versions: versioned SwiftData schemas used for migration safetyChatBot/ImageVisionAnalyzer.swift: OCR and image classification helper
- Xcode with support for
FoundationModels - Minimum supported device for full Apple Intelligence functionality:
iPhone 15 Pro - iOS device or simulator compatible with the app target
- Apple Intelligence / system model availability for chat responses
- Chat sessions are stored locally.
- Uploaded images are stored with chat messages so they can be shown again in chat history.
- Vision extraction is hidden from the user interface and only used internally for better responses.
- SwiftData uses a versioned migration structure so future updates are safer for existing users.