Tetrix Blog

Introducing Twaps: Bringing Web-like Dynamics to Native macOS Apps

March 7, 2025 | by Noah Moller

Aqua Marine

The Vision: Dynamic Native UI Components

At Tetrix, we’ve been exploring a question that has intrigued us for some time: What if native could have the same dynamic content model that makes the web so powerful?

The web revolutionized content distribution by allowing dynamic loading of content without requiring application updates. When you visit a website, you’re always seeing the latest version – no downloads or updates required. This model has given web applications incredible flexibility and has enabled rapid iteration and deployment.

But native applications? They’ve traditionally been static. To update a UI component, you need to release a new version of your app, and users need to download and install that update. This process creates friction and slows down innovation.

That’s why we’re excited to introduce Twaps – an experimental framework that brings web-like dynamics to native macOS applications.

What is Twaps?

Twaps (The Web for Apps) is a Swift-based framework that provides a declarative DSL—modeled after SwiftUI—for building self-contained, dynamic native macOS UI modules. These modules are compiled into deployable binaries (dynamic libraries) that can be dynamically loaded by client apps, effectively creating “the web for native macOS apps.”

With Twaps, developers can:

  • Create modular UI components using Swift and SwiftUI
  • Compile these components into dynamic libraries
  • Distribute them independently from the main application
  • Load and display them at runtime without app recompilation
  • Update them remotely without requiring app updates

The Twaps Ecosystem

The Twaps ecosystem consists of three main components:

1. TwapsCLI

A command-line tool for building and publishing Twaps. This component:

  • Compiles Swift source files into dynamic libraries
  • Provides a DSL for creating Twaps (experimental)
  • Pushes Twaps to a TwapsServer for distribution

2. TwapsServer

A simple server for hosting and distributing Twaps. This component:

  • Hosts Twaps (dynamic native UI modules)
  • Serves Twaps to client applications
  • Manages Twap metadata and versioning

3. TwapsClient

A macOS app for loading and displaying Twaps. This component:

  • Loads Twaps from a TwapsServer
  • Compiles Twaps into dynamic libraries
  • Displays Twaps in a native macOS interface

A Simple Example

Let’s look at a simple example of a Twap:

import SwiftUI
import AppKit

@_cdecl("createDynamicView")
public func createDynamicView() -> UnsafeMutableRawPointer {
    let view = AnyView(
        VStack {
            Text("Hello from my first Twap!")
                .font(.largeTitle)
                .foregroundColor(.blue)

            Button("Click Me") {
                print("Button clicked!")
                let alert = NSAlert()
                alert.messageText = "Hello!"
                alert.informativeText = "This is my first Twap!"
                alert.runModal()
            }
            .padding()
            .background(Color.blue)
            .foregroundColor(.white)
            .cornerRadius(10)
        }
        .padding()
        .frame(width: 400, height: 300)
    )

    let hostingController = NSHostingController(rootView: view)
    return Unmanaged.passRetained(hostingController).toOpaque()
}

// Dummy global to force the export of createDynamicView
public let __forceExport_createDynamicView: Void = {
    _ = createDynamicView
}()

This code defines a simple UI component with a title and a button. When compiled into a dynamic library and loaded by the TwapsClient, it will display a window with this UI.

To push this Twap to the server, you would run:

swift run TwapsCLI push MyFirstTwap.swift --url myfirst.twap --yes

Then, in the TwapsClient app, you would enter myfirst.twap and click “Go” to load and display the Twap.

Use Cases and Possibilities

The potential applications for Twaps are vast:

  1. Dynamic Content: News feeds, product listings, or any content that needs frequent updates
  2. Feature Flags: Roll out new features to users without requiring app updates
  3. A/B Testing: Test different UI variations with different user segments
  4. Plugin Systems: Allow third-party developers to extend your app’s functionality
  5. Remote Configuration: Update app behavior and appearance without releasing new versions

The Future of Twaps

We see Twaps as a starting point for a new way of thinking about native app development. In the future, we envision:

  • Support multiple platforms like Linux and Windows
  • Enhanced security model with code signing
  • Dependency management for Twaps
  • A marketplace for discovering and sharing Twaps

Join the Experiment

Twaps is open source and available on GitHub. We invite developers to explore the code, try it out, and contribute to the project:

  • Twaps: The main repository with documentation and examples
  • TwapsCLI: The command-line tool for building and publishing Twaps
  • TwapsServer: The server for hosting and distributing Twaps
  • TwapsClient: The macOS app for loading and displaying Twaps

We’re excited to see what the community builds with Twaps and how this experiment evolves. If you’re interested in dynamic UI components for native apps, we’d love to hear your thoughts and feedback.

Conclusion

At Tetrix, we believe in pushing the boundaries of what’s possible with native app development. Twaps represents our vision for a more dynamic, flexible future for macOS applications – one where updates are seamless, deployment is rapid, and innovation is unhindered by distribution constraints.

While Twaps is still experimental, we hope it sparks discussion and collaboration around the idea of bringing web-like dynamics to native app development. We’re excited to continue exploring this space and to see how the community responds to this new approach.

RELATED POSTS

View all

view all