RustMaui brings the performance, safety, and joy of Rust directly into your .NET MAUI applications on Android, iOS, MacCatalyst and Windows.
It's a combination of cross-platform Rust build support and bindings generators and includes everything you need:
- A friendly
dotnet toolfor instant setup - Automatic build-time Rust bindings generation
- Optional
dotnet newtemplate for new projects
Read the article behind this project
dotnet tool install --global RustMauidotnet tool update --allrustmaui new MyAwesomeApprustmaui init .When you create MAUI+Rust app from template or add Rust support to an existing app, simple Rust files are created and added to your solution. Appropriate package is added to your MAUI app to handle Rust build and auto-generate Rust bindings.
MyApp/
├── src/
│ └── MauiRust/
│ ├── AppShell.xaml
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Rust.cs <-- override bindings here
│ ├── Rust.Generated.cs <-- auto-generated bindings
│ └── MauiRust.csproj
├── rust/
│ ├── Cargo.toml
│ └── lib.rs <-- add exported Rust code here
└── MyApp.sln
Your Rust library will be automatically built and packaged along with your MAUI project on Android, iOS, MacCatalyst or Windows. Prerequisites apply.
On Apple targets, RustMaui uses one consistent model:
- iOS device and iOS simulator: Rust is linked as a static archive and imported from
__Internal - MacCatalyst: Rust is bundled as a dynamic library and imported by library name
If you write custom Rust platform-specific loading code, treat all iOS targets as the static-link path and reserve dynamic loading behavior for MacCatalyst.
On first build the generator creates Rust.cs if it is missing and regenerates Rust.Generated.cs on every build.
If you want a different base name, set RustBindingsName in your app project. For example, RustBindingsName=MyBindings gives you MyBindings.cs, MyBindings.Generated.cs, and a MyBindings partial class.
Write a Rust export:
#[no_mangle]
pub extern "C" fn compute_me(value: f32) -> f32 {
value * 2.0
}The generator automatically emits a C# binding following .NET naming conventions:
// Rust.Generated.cs — do not edit
[LibraryImport(Lib, EntryPoint = "compute_me")]
[UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial float ComputeMe(float value);Call it directly from your .NET code:
var result = Rust.ComputeMe(3.14f);The primary entry point: a .NET tool for both greenfield and existing-app setup.
- install with
dotnet tool install --global RustMaui - run
rustmaui new MyAppto create a new app from the shared scaffold - run
rustmaui init path/to/MyApp.csprojto add Rust boilerplate andRustMaui.Generatorsto an existing app
Package docs: src/RustMaui.Tool/README.md.
Build-time package that discovers Rust exports, creates the user-owned companion file when missing, generates the bindings file, and wires Rust native build targets.
- ships the generator/build package
- packs
build/RustMaui.Generators.targets - produces the analyzer/build assets consumed by MAUI apps
Package docs: src/RustMaui.Generators/README.md.
An optional dotnet new template package for new-app-only flows. It scaffolds a MAUI app already configured to use the generator package.
- ships the
dotnet new rustmauitemplate - carries the scaffold under
src/RustMaui.Templates/content/MauiRust - emits a scaffolded app that references
RustMaui.Generators
Package docs: src/RustMaui.Templates/README.md
Please feel free to bring in your works, we need you!
Pack all three packages:
.\dev\pack-all.ps1Pack one package:
.\dev\pack.ps1 -Project src/RustMaui.Generators/RustMaui.Generators.csprojValidate the template against locally packed packages:
.\dev\validate-template.ps1That validator packs all three packages, installs the local template package, generates a temporary app outside the repo tree, reuses the local package folder as a NuGet source, and runs a Windows build against the generated app.
The template remains available, but the preferred install path for end users is dotnet tool install --global RustMaui.
See nugets.md for the shared GitHub Actions release workflow and required secrets.
