SwiftTUI — a Terminal UI framework for Swift

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:

  1. swift package init
  2. an spm dependency + import
  3. @main struct MyApp: App { /*…*/ }.

Key Features

  • SwiftUI-faithful API and behavior[2]:
    • State@State, @Environment, @Binding, @Observable,@FocusState, etc.
    • Updatesvar body: some View, .task(id:), .onChange(of:), etc.
    • LayoutV/H/ZStack, ScrollView, GeometryProxy, Shape, overlays, alignment guides, etc.
    • Gestures and keys — click/tap, hover, drag, key commands
    • Animations + transitions — PhaseAnimator, .bouncy,
  • Modern feature support, with graceful fallback behavior. The framework handles terminal negotiation and the ANSI/Xterm/OSC/TTY details.
  • 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

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.


  1. Here's one curated index that filters by language https://terminaltrove.com/explore/ ↩︎

  2. There are changes to represent the realities of the terminal — but even the divergences aim to follow the spirit of the API ↩︎

  3. Very soon! It's on main, but not in a tagged release ↩︎

  4. 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 :) ↩︎

  5. Because without them performance would be awful :). See Rens Breuer's diffing article for an example. ↩︎

28 Likes

Windows support has landed.
SwiftTUI terminal apps now for macOS, Linux, Windows, and WASI.

If you get a chance to take a look:

  • Try cloning the QuickStart swift-tui-counter-demo
  • Or just spin up your own app! SwiftUI syntax should get you there.

If so, let me know! Either just here, or open a GitHub issue on the repo to report anything funky — or just send your first impressions :)

5 Likes

I like the design and reuse the SwiftUI semantics, thanks for sharing

2 Likes

I'm loving this project so much. Looks like some serious work went into it already, thank you!

1 Like

I think text interfaces are an often unappreciated area, and I'm glad the AI coding tools have given them more visibility. The first time i saw Claude Code, I remember thinking that I haven't really seen such an advanced console app. (Not since DOS days at least, but certainly never on a Unix system).

I remember seeing rensbreur's version many years ago and thought it was a great idea. So I think I'm really glad you've taken up the mantle!

Not sure if it's useful, but it looks like there's another similar project that's still actively being developed:

3 Likes

TUIKit is cool. I'm super impressed by the documentation clarity.
It would be fun to collaborate!

In terms of comparing/contrasting the projects beyond platform support: SwiftTUI has a (potentially unreasonable!) emphasis on implementing SwiftUI functionality in the same way SwiftUI itself does. This puts a big performance burden on the framework (SwiftUI takes on a lot of complexity, and it does so in very sophisticated ways).

The potential downsides here are performance, binary size, bugs, etc — but the upside is the ability to re-implementing exciting functionality animations, gestures, etc. (and learning a lot in the process!)

3 Likes