Open-Source Wikis

/

Tauri

/

Systems

/

Mobile

tauri-apps/tauri

Mobile

Tauri's mobile support shipped as part of v2. Both Android (Kotlin) and iOS (Swift) targets are first-class: the same Rust app code compiles for desktop and mobile, the same plugin trait, the same IPC commands. The differences live in the build pipeline and a handful of bridge files.

Where mobile lives in the repo

Concern Path
Mobile bridge (Rust) crates/tauri/src/plugin/mobile.rs
Android plugin Kotlin sources crates/tauri/mobile/android/
iOS plugin Swift sources crates/tauri/mobile/ios/
Mobile build-time helpers crates/tauri-build/src/mobile.rs
Mobile codegen helpers crates/tauri-codegen/ (target-aware code paths)
CLI Android subcommand crates/tauri-cli/src/mobile/android/
CLI iOS subcommand crates/tauri-cli/src/mobile/ios/
Mobile entry-point macro tauri::mobile_entry_point in crates/tauri-macros/src/lib.rs
Sample mobile app entry helpers (init.rs) crates/tauri-cli/src/mobile/init.rs

Build flow

graph TD
    User["tauri android dev / build"] --> CLI["crates/tauri-cli/src/mobile/android/"]
    CLI -->|"cargo-ndk"| RustLib["compile lib.so for ABI"]
    CLI -->|"gradle wrapper"| AndroidProj["src-tauri/gen/android"]
    AndroidProj -->|"loads .so"| App["Android app"]
    User2["tauri ios dev / build"] --> CLIios["crates/tauri-cli/src/mobile/ios/"]
    CLIios -->|"cargo + xcodebuild"| Framework["compile static lib"]
    CLIios -->|"xcrun simctl / xcodebuild"| iOSProj["src-tauri/gen/apple"]
    iOSProj -->|"links static lib"| AppiOS["iOS app"]

The CLI generates Android/iOS project skeletons under src-tauri/gen/ on first init and orchestrates rebuilds afterwards. cargo-ndk is required for Android cross-compilation; iOS uses Apple's toolchain.

The bridge

A plugin can declare native code that runs on the Kotlin/Swift side rather than in Rust. The plugin's Builder::android_init / ios_init register a class/Swift module name; at runtime the bridge translates IPC calls into JNI / swift-rs calls and back.

crates/tauri/src/plugin/mobile.rs:

  • Holds the PluginHandle types for Android and iOS.
  • Routes plugin commands either through the Rust dispatcher (desktop-style) or through the native bridge (mobile).
  • Decodes/encodes JSON payloads for the JNI/Swift boundary.

crates/tauri/mobile/android/ provides the PluginManager.kt that loads native plugin classes via reflection and translates between JS and Rust through Tauri's IPC.

iOS uses swift-rs (crates/tauri/Cargo.toml) so Rust can call exported Swift functions; the entry point is generated by tauri::mobile_entry_point.

Cargo and CFG

crates/tauri/Cargo.toml carves out three target groups:

  • cfg(target_os = "android"): pulls in jni.
  • cfg(all(target_vendor = "apple", not(target_os = "macos"))): pulls in libc, swift-rs, objc2-ui-kit.
  • cfg(any(target_os = "android", all(target_vendor = "apple", not(target_os = "macos")))): shared mobile deps (bytes, reqwest, optional rustls).

The mobile cfg alias (defined in crates/tauri/build.rs) is the conventional gate inside Rust code:

#[cfg(mobile)]
fn mobile_only_thing() {}

#[cfg(desktop)]
fn desktop_only_thing() {}

File associations on mobile

The recent commit feat(mobile): add file association support (#14486) added handling for files that are opened via the OS sharing into the app. The corresponding code paths added intent filters on Android and document type entries on iOS, plumbed through crates/tauri-build/src/mobile.rs and the templates in crates/tauri-cli/src/mobile/.

Files at a glance

File Role
crates/tauri/src/plugin/mobile.rs Cross-platform mobile bridge for plugins
crates/tauri/mobile/android/PluginManager.kt Loads native plugins via JNI
crates/tauri/mobile/ios/ Swift glue and entry hooks
crates/tauri-build/src/mobile.rs Build-time mobile glob and emission of Cargo link-search directives
crates/tauri-cli/src/mobile/init.rs Generates src-tauri/gen/android and src-tauri/gen/apple
crates/tauri-cli/src/mobile/android/ tauri android subcommands
crates/tauri-cli/src/mobile/ios/ tauri ios subcommands
.github/workflows/test-android.yml CI smoke test for Android builds

Cross-references

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Mobile – Tauri wiki | Factory