JFFI
A cross-platform framework for building native applications with Rust business logic and platform-native UIs.
π― Philosophy
Write your business logic once in Rust. Build native UIs for each platform.
- Write business logic once in Rust
- Use native UI frameworks (SwiftUI, Jetpack Compose, WinUI, etc.)
- Get truly native performance and platform feel
- Maintain type safety end-to-end via UniFFI
π Quick Start
Installation
# Install JFFI CLI
Create Your First App
# Create a new app with all platform support
# Navigate and run
That's it! The app builds, compiles Rust, generates platform bindings, and launches automatically.
π± Supported Platforms
| Platform | Status | UI Framework | Language |
|---|---|---|---|
| iOS | β Ready | SwiftUI | Swift |
| macOS | β Ready | SwiftUI | Swift |
| Android | β Ready | Jetpack Compose | Kotlin |
| Linux | β Ready | GTK 4 + Libadwaita | Python |
| Web | β Ready | Vanilla JS + WASM | JavaScript |
| Windows | β Ready | WinUI 3 | C# |
ποΈ Project Structure
my-app/
βββ core/ # Pure Rust business logic
β βββ src/lib.rs # Your app logic here
β βββ Cargo.toml
β
βββ ffi/ # FFI layer (auto-scaffolded)
β βββ src/lib.rs # UniFFI exports
β βββ Cargo.toml
β
βββ platforms/
β βββ ios/ # iOS SwiftUI app
β βββ *App.swift
β βββ AppState.swift
β βββ ContentView.swift
β βββ *.xcodeproj # Auto-generated
β
βββ jffi.toml # Framework configuration
π‘ Development Workflow
1. Write Business Logic (Once)
core/src/lib.rs:
2. Expose via FFI (Auto-scaffolded)
ffi/src/lib.rs:
3. Build & Run
For iOS:
For Android:
For macOS:
For Linux:
For Web:
For Windows:
This automatically:
- iOS/macOS: Compiles Rust, generates Swift bindings, creates Xcode project, builds and launches
- Android: Compiles Rust for 3 architectures, generates Kotlin bindings, starts emulator, builds APK, installs and launches app
- Linux: Compiles Rust, generates Python bindings, installs dependencies (GTK 4, build tools), builds and launches GTK app
- Web: Compiles Rust to WASM, generates JavaScript bindings, installs npm dependencies, starts Vite dev server
- Windows: Compiles Rust, generates C# bindings with uniffi-bindgen-cs, builds with MSBuild/dotnet, launches WinUI 3 app
4. Use in Native UI
platforms/ios/ContentView.swift:
Button("Add Item") {
appState.addItem(id: UUID().uuidString, title: newItem)
}
The generated bindings make Rust functions available in Swift!
β‘ Hot Reload
JFFI works seamlessly with native IDE hot reload plus automatic Rust rebuilding.
iOS/macOS Workflow
# Start Rust file watcher
# In Xcode:
# 1. Open platforms/ios/*.xcodeproj in Xcode
# 2. Run the app (Cmd+R)
# 3. Edit Swift files β Xcode hot reloads automatically β‘
# 4. Edit Rust files β Watcher rebuilds dylib β Press Cmd+B in Xcode
Android Workflow
# Start Rust file watcher + Android Studio
# In Android Studio:
# 1. Press βΆοΈ to run the app
# 2. Edit Kotlin files β Compose hot reloads automatically β‘
# 3. Edit Rust files β Watcher rebuilds .so β Rebuild in Android Studio
Linux Workflow
# Start Rust file watcher
# The app will auto-restart when Rust code changes
# 1. Edit Python/GTK files β Save and re-run
# 2. Edit Rust files β Watcher rebuilds .so β App auto-restarts β‘
Web Workflow
# Start Rust file watcher + Vite dev server
# Vite provides hot reload for JS/CSS changes
# 1. Edit HTML/JS/CSS β Vite hot reloads instantly β‘
# 2. Edit Rust files β Watcher rebuilds WASM β Refresh browser
How It Works
Native UI Changes:
- iOS/macOS: Edit
.swiftfiles β Xcode hot reloads instantly - Android: Edit
.ktfiles β Compose hot reloads automatically - Web: Edit
.js/.cssfiles β Vite hot reloads instantly - Use native IDE features (SwiftUI previews, Compose previews, etc.)
- Full debugging support
Rust Changes:
- Edit any
.rsfile incore/orffi/ - File watcher rebuilds Rust library automatically
- Rebuild in native IDE to use new Rust code
- App updates with new business logic
Best of Both Worlds
β Native IDE experience - Use all platform IDE features β Native UI previews - SwiftUI/Compose previews work β Native hot reload - Instant UI updates β Rust auto-rebuild - No manual cargo commands β Full debugging - Native debuggers work normally
π§ CLI Commands
# Create new project
# Build for platform
# Run on platform (builds automatically)
# Development mode (auto-rebuild on changes)
# Add platform to existing project
# List available platforms
π How It Works
βββββββββββββββββββββββββββββββββββββββββββ
β Your Rust Business Logic β
β (core/src/lib.rs) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββ
β UniFFI FFI Layer β
β (ffi/src/lib.rs) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββ
β Auto-Generated Bindings β
β (Swift, Kotlin, C#, etc.) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββ
β Native Platform UI β
β (SwiftUI, Compose, WinUI, etc.) β
βββββββββββββββββββββββββββββββββββββββββββ
π Configuration
jffi.toml:
[]
= "my-app"
= "0.1.0"
[]
= ["ios"]
[]
= "16.0"
= "com.example.myapp"
π Why JFFI?
| Feature | JFFI | Flutter | React Native |
|---|---|---|---|
| Business Logic | Rust | Dart | JavaScript |
| UI | Native | Cross-platform | Near-native |
| Performance | Native | Good | Good |
| Platform Feel | Native | Consistent | Near-native |
| Type Safety | End-to-end | Strong | Weak |
Use JFFI when:
- You want truly native UI and performance
- You have platform-specific design requirements
- You want to leverage native UI libraries
- You need Rust for business logic (performance, safety)
π οΈ Development
Prerequisites
- Rust toolchain
- iOS: Xcode, iOS Simulator
- Android: Android Studio, Android SDK, Android Emulator (auto-configured)
- macOS: Xcode
- Linux: GTK 4, Libadwaita, Python 3 (auto-installed by setup script)
- Web: Node.js, npm (for Vite dev server)
- Windows: .NET SDK 8.0+, Visual Studio Build Tools or MSBuild
Building the CLI
πΊοΈ Roadmap
- CLI tool foundation
- iOS support with SwiftUI
- macOS support with SwiftUI
- Android support with Jetpack Compose
- Linux support with GTK 4 + Python
- Web support with Vanilla JS + WASM
- Windows support with WinUI 3 + C#
- Automatic Xcode project generation
- Automatic Android project generation
- One-command build and run (iOS, macOS, Android, Linux, Web, Windows)
- Hot reload for iOS (Xcode-native workflow)
- Hot reload for Android (Android Studio-native workflow)
- Hot reload for Linux (auto-restart workflow)
- Hot reload for Web (Vite hot reload)
- Automatic emulator/simulator management
- Auto-install build dependencies (targets, NDK, GTK, WASM, wasm-bindgen, uniffi-bindgen-cs, etc.)
π€ Contributing
Early-stage framework. Contributions welcome!
High priority:
- Additional platform features and improvements
- State persistence (SQLite/local storage)
- Advanced UI components and patterns
- Hot reload for Windows (file watcher workflow)
π License
MIT
π Acknowledgments
- UniFFI - FFI bindings generator
- The Rust community
Built with β€οΈ and Rust