Rust-to-SwiftUI Meta-Compiler
A Zig-based code generator that bridges the Rust↔Swift divide. Write your domain models once in Rust, get type-safe SwiftUI ViewModels automatically.
Most developers:
1. Write Rust logic
2. Manually write Swift wrappers
3. Apple releases iOS 18, deprecates @StateObject for @Observable
4. Spend 3 weeks rewriting 50 files manually
This is Slop.
With Synapse:
1. Update swift_templates.zig line 12
2. Run just gen-ui
3. Entire app upgraded to latest iOS standards instantly
You’ve effectively decoupled your IP (Rust) from the whims of the platform (Apple).
= Build Synapse
just build
= Generate Swift from Rust
just gen-ui
= Check the output
cat examples/swift/Generated.swift#[derive(Synapse)]
pub struct PlayerState {
pub coffee_count: i32,
pub is_drifting: bool,
}| Command | Description |
|---------|-------------|
| just build | Build the Synapse binary |
| just gen-ui | Generate Swift ViewModels |
| just gen-ui-legacy | Generate for iOS 14-16 |
| just test | Run all tests |
| just deploy-ios ~/MyApp | Generate and copy to Xcode project |
| just help | Show CLI help |
src/
├── generators/
│ └── synapse.zig # Main entry point
├── parser/
│ └── rust_parser.zig # Parses Rust struct definitions
└── templates/
└── swift_templates.zig # Apple Store compliance layerThe templates in swift_templates.zig define "Current Best Practice SwiftUI".
When Apple announces iOS 19 with new concurrency:
1. Update the template once
2. Run just gen-ui
3. Commit, upload to App Store
Your "Eternal Maintenance" problem is solved.
| Rust | Swift |
|------|-------|
| i32, i64 | Int, Int64 |
| u32, u64 | UInt, UInt64 |
| f32, f64 | Float, Double |
| bool | Bool |
| String | String |
| Vec<T> | [T] |
| Option<T> | T? |
| Custom structs | Passed through |
Synapse complements UniFFI:
-
UniFFI gives you data structures (
struct Reef) -
Synapse gives you UI bindings (
class ReefViewModel)
Use both together:
#[derive(uniffi::Object, Synapse)] // Both!
pub struct Reef {
pub lat: f64,
pub lon: f64,
}