DevTechie/Build a Private AI Chatbot for macOS Using SwiftUI, Ollama & Local LLMs

  • $24.99

Build a Private AI Chatbot for macOS Using SwiftUI, Ollama & Local LLMs

  • Course
  • 25 Lessons

A complete, stage-by-stage guide to building Ollama Swift — a native macOS SwiftUI client for a locally running Ollama(https://ollama.com) server and local AI models. You will end up with a complete macOS app project in this tutorial: a model library with live download progress, a streaming chat transcript rendered as Markdown, a SwiftData-backed sidebar with folders, search and Markdown export.

Contents

Introduction

Course Introduction
Preview
App Demo
Preview

Part 0 - Create The Project

What we are doing: creating the Xcode project and setting exactly the options that the finished app depends on. Two of them (the sandbox and the entitlements) will silently break networking or file access later if they are wrong, so we do them now rather than debugging them later.

Create the project
Part-0 Source Code: Starter Project

Part 1 - Talk to Ollama: the Model Library

What we are doing: everything that touches the network, and the first screen that proves it works. By the end of this part the app lists the models installed on your machine, downloads a new one with a live progress bar and transfer speed, deletes and duplicates models, and shows a proper error banner when Ollama is not running. No chat yet, no database yet — just a real, useful screen.

Why this order: the chat in Part 2 is the same networking code with a different payload. Getting OllamaController, the error vocabulary and the design tokens right first means Part 2 is almost entirely about SwiftUI and SwiftData.

Part 1: Talk to Ollama
Part 1: Finished Demo
Part 1: Source code

Part 2: Conversations and Chat

What we are doing: the heart of the app. We define the SwiftData schema (conversations, messages, attachments, folders), own the container explicitly, write the controller that streams a reply token by token, and build the transcript and composer that show it. By the end, you can hold a real conversation, stop it mid-sentence, regenerate it, edit a question and ask again, attach images for a vision model, and quit and relaunch to find everything intact.

01. Part 2: Add Markdown Package
02. Part 2: Conversations and Chat
03 Part2: Finished Demo
Part 2: Source Code

Part 3: The sidebar: folders, search and export

What we are doing: turning the placeholder list into the real sidebar. Folders you can create, rename, and drag chats into; a search field that looks inside message bodies and shows you the matching excerpt; per-chat rename, duplicate, delete and Markdown export.

01. Part 3: Markdown Document
02 Part 3: Conversation List View
Part 3: Source Code

Part 4 — Settings and the conversation inspector

What we are doing: the last two screens. A settings sheet for host, port and timeouts, and a trailing inspector that exposes every sampling parameter per conversation, with a context gauge and the statistics of the last response. We also add the menu commands: ⌘, for settings and ⌘T for a new window tab.


01. AppNavigation
02. Settings View
03. Parameter Controls
04. Conversation Inspector View
05. Edit Chat View
06. Edit Content View
07. Edit Conversation List View Edits
08. Final Edit App File
Ollama Swift_Part4_Source Code.zip

Part 5 (optional) — The test suite

What we are doing: filling in the Ollama SwiftTests target Xcode created in Part 0. There are 105 tests and they run in about a second, because none of them touch the network: the SwiftData ones build an in-memory ModelContainer from ChatStore.schema, and the decoding ones use JSON fixtures copied from a live server.

The test suite
Ollama Swift_Part 5 Source Code.zip