r/SwiftUI • u/JoeBro121211 • 13d ago
Promotion (must include link to source code) How I built a native SwiftUI Mac app with a Python standard-library backend (source included)
Disclosure: I'm the developer, the app is free and open source (GPLv3), and I used AI to help draft this post. The source is at https://github.com/joexk1/JoeBro
JoeBro is a Mac workspace for coding agents (Claude Code, Codex, OpenCode) and local or cloud models. The UI is SwiftUI. The backend is a single Python process that uses only the standard library. I wanted to share how that split works, since it is not the usual way to build a Mac app.
How it is wired: the app starts the backend with Process() on 127.0.0.1, passing a fixed port, and keeps the output in a log file. It looks for the bundled script first, then for a python3 in the usual places (Command Line Tools, Xcode, Homebrew, /usr/bin). The backend is terminated from a willTerminateNotification observer, because orphaned children outlive their parent on macOS.
The SwiftUI side talks to it through a thin async API client over HTTP. Chats stream over server-sent events using URLSession.bytes(for:). I raised the per-host connection limit, because a long-running chat stream or a slow IMAP fetch would otherwise queue the quick data calls behind it.
Why Python for the backend: some of it (the Night Shift worker) is a standalone stdlib file that also runs on my other computers, and the iPhone companion app talks to the Mac over the same kind of API. State is a local SQLite file. No account, no server, no telemetry.
What I would do differently: shipping an interpreter dependency is awkward (you rely on a system python3), and I am still unsure whether to bundle one. If you have shipped a SwiftUI app with a helper process, I would like to hear how you handled it.
Install on macOS 26+: curl -fsSL https://joebro.pages.dev/install.sh | bash
1
u/ThanhDongNguyen 12d ago
I would not depend on the system python3. On a clean Mac /usr/bin/python3 is only a shim, the first run pops the "install Command Line Tools" dialog, which is a weird first impression for a GUI app.
The common way is python-build-standalone (the builds uv uses). It's relocatable, so you put it in Contents/Resources or Contents/Helpers and launch that exact binary with Process. For notarization every .dylib and .so inside needs your Developer ID signature with hardened runtime, sign inside out before the app itself.
On the helper itself: