Hey everyone — I'd like to introduce SwiftTUI. (tagline: SwiftUI's semantics drawn to terminal cells.)
Terminal apps are having a renaissance. The Rust and Go communities in particular[1] have built a lot of impressive tools, and neat niche apps.
Swift has felt weirdly underrepresented: despite the language being at a perfect level of abstraction, having a powerful package ecosystem, and providing good platform support, Swift-based TUI apps are scarce.
Why SwiftTUI
SwiftTUI aims to make TUI development trivially accessible to the Swift community.
It implements a surprisingly powerful portion of the SwiftUI API you already know, and makes spinning up a TUI a three step process:
swift package init- an spm dependency + import
@main struct MyApp: App { /*…*/ }.
Key Features
- SwiftUI-faithful API and behavior[2]:
- State —
@State,@Environment,@Binding,@Observable,@FocusState, etc. - Updates —
var body: some View,.task(id:),.onChange(of:), etc. - Layout —
V/H/ZStack,ScrollView,GeometryProxy,Shape, overlays, alignment guides, etc. - Gestures and keys — click/tap, hover, drag, key commands
- Animations + transitions —
PhaseAnimator,.bouncy,
- State —
- Modern feature support, with graceful fallback behavior. The framework handles terminal negotiation and the
ANSI/Xterm/OSC/TTYdetails. - Cross platform: the frameworks supports macOS, Linux, and soon Windows[3]
- … and builds native[4] GUIs for for Web, iOS, macOS, and Android.
- Swift 6.3 implementation, open source, with strict concurrency — and as many of SwiftUI's optimizations, tricks, and structural insights as one can find by trawling the public web.[5]
Where to find it
- Website: https://SwiftTUI.sh — live web demo + examples + getting started + how it works
- GitHub: SwiftTUI/swift-tui — the main project repo
- Demo/Quickstart: swift-tui-counter-demo — the obligatory counter demo :)
SwiftTUI is a young project — but it's very ready for testing and feedback.
Take a look and and let me know how it goes.
This 'SwiftTUI' is not the first framework to use the name. Shout-out to Rens Breuer, whose earlier SwiftTUI implementation and associated articles on structural diffing and the attribute graph I have learned a lot from — and who now works on the SwiftUI team itself.
Here's one curated index that filters by language https://terminaltrove.com/explore/ ↩︎
There are changes to represent the realities of the terminal — but even the divergences aim to follow the spirit of the API ↩︎
Very soon! It's on main, but not in a tagged release ↩︎
The cells are drawn directly. There's no xterm.js or libghostty. But the cells are still cells. This is a TUI framework after all :) ↩︎
Because without them performance would be awful :). See Rens Breuer's diffing article for an example. ↩︎