Introduction to Shaft

Shaft is a cross-platform UI framework designed for high-performance applications with a focus on simplicity and customizability. It combines the proven concepts from Flutter with Swift’s native performance.

What is Shaft?

Shaft is essentially a port of Flutter’s framework to Swift, bringing the best of both worlds:

  • Flutter’s declarative UI paradigm - Build UIs with composable widgets
  • Swift’s native performance - ARC-based memory management, no GC overhead
  • Direct platform access - No complex bridging, direct C/C++ interop
  • Simple architecture - Just a Swift package, easy to fork and customize

Key Features

⚡ Lightning Fast Performance

Shaft leverages Swift’s ARC (Automatic Reference Counting) for deterministic memory management, resulting in:

  • Native performance with compiled Swift code
  • Lower memory overhead without GC pauses
  • True native multi-threading support
  • Direct access to low-level graphics APIs

🎨 Declarative UI

Build beautiful, responsive interfaces with an intuitive, declarative syntax:

Hello World Example

📦 Effortless State Management

Thanks to Swift’s @Observable framework, Shaft automatically updates the UI when data changes:

import Shaft

@Observable class Counter {
    var count = 0
}

let counter = Counter()

class CounterView: StatelessWidget {
    func build(context: BuildContext) -> Widget {
        Column {
            Text("Count: (counter.count)")
            
            Button {
                counter.count += 1
            } child: {
                Text("Increment")
            }
        }
    }
}

When counter.count changes, Shaft automatically triggers a UI rebuild. No manual state management required!

🔥 Hot Reload

Shaft supports cross-platform hot reload via SwiftReload, allowing you to see changes instantly without restarting your application.

🛠️ Simple & Hackable

Unlike most frameworks, Shaft is just a single Swift package:

  • No build infrastructure required
  • No special toolchain needed
  • Easy to fork and customize
  • Direct source code access

You can modify the framework, use it, and distribute it without complex compilation or custom engine setup.

Architecture Overview

Shaft consists of four main components:

┌─────────────────────────────────────┐
│          Your App                   │
├─────────────────────────────────────┤
│         ShaftKit                    │  ← High-level widgets
├─────────────────────────────────────┤
│      Shaft Framework                │  ← Core framework (ported from Flutter)
├─────────────────────────────────────┤
│  Backend    │    Renderer           │  ← Platform & graphics abstractions
│  (SDL3)     │    (Skia/Metal)       │
└─────────────────────────────────────┘
  • Framework: Port of Flutter’s core framework to Swift
  • Backend: Platform abstraction (events, windows, input)
  • Renderer: Graphics backend (Skia, Metal, etc.)
  • ShaftKit: Built-in customizable widget library
Shaft Architecture Diagram

Shaft Architecture Diagram

Supported Platforms

Shaft runs on:

  • macOS
  • Linux
  • Windows
  • Web - Via WebAssembly (experimental)

Next Steps

Ready to get started? Check out:

Or explore our interactive tutorials to see Shaft in action!