jffi 0.1.0

Cross-platform framework for building native apps with Rust business logic and platform-native UIs
jffi-0.1.0 is not a library.

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
cargo install --path cli

Create Your First App

# Create a new app with all platform support
jffi new my-app --platforms ios,macos,android,linux,web,windows

# Navigate and run
cd my-app
jffi run --platform ios      # iOS Simulator
jffi run --platform macos    # macOS app
jffi run --platform android  # Android Emulator
jffi run --platform linux    # Linux GTK app
jffi run --platform web      # Web browser
jffi run --platform windows  # Windows app

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:

pub struct App {
    items: Vec<Item>,
}

impl App {
    pub fn add_item(&mut self, id: String, title: String) {
        self.items.push(Item { id, title, completed: false });
    }
}

2. Expose via FFI (Auto-scaffolded)

ffi/src/lib.rs:

#[derive(uniffi::Object)]
pub struct FfiApp {
    app: Mutex<App>,
}

#[uniffi::export]
impl FfiApp {
    pub fn add_item(&self, id: String, title: String) -> Vec<ItemViewModel> {
        let mut app = self.app.lock().unwrap();
        app.add_item(id, title);
        app.get_items().iter().map(ItemViewModel::from).collect()
    }
}

3. Build & Run

For iOS:

jffi run --platform ios              # Simulator
jffi run --platform ios --device     # Physical device

For Android:

jffi run --platform android          # Emulator (auto-starts)

For macOS:

jffi run --platform macos

For Linux:

jffi run --platform linux

For Web:

jffi run --platform web

For Windows:

jffi run --platform 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
jffi dev --platform ios

# 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
jffi dev --platform android

# 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
jffi dev --platform linux

# 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
jffi dev --platform web

# 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 .swift files β†’ Xcode hot reloads instantly
  • Android: Edit .kt files β†’ Compose hot reloads automatically
  • Web: Edit .js/.css files β†’ Vite hot reloads instantly
  • Use native IDE features (SwiftUI previews, Compose previews, etc.)
  • Full debugging support

Rust Changes:

  • Edit any .rs file in core/ or ffi/
  • 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
jffi new <name> --platforms <platforms>

# Build for platform
jffi build --platform <platform>
jffi build --platform ios --device          # Build for physical device

# Run on platform (builds automatically)
jffi run --platform <platform>
jffi run --platform ios --device            # Run on physical device

# Development mode (auto-rebuild on changes)
jffi dev --platform <platform>

# Add platform to existing project
jffi add <platform>

# List available platforms
jffi 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:

[package]
name = "my-app"
version = "0.1.0"

[platforms]
enabled = ["ios"]

[platforms.ios]
deployment_target = "16.0"
bundle_id = "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

cargo build --package jffi
cargo run --package jffi -- --help

πŸ—ΊοΈ 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