Expand description
Interface for building Tauri plugins.
A Tauri plugin is a Rust crate that extends a Tauri application with commands, state,
lifecycle hooks and - optionally - Android and iOS native code. This crate holds the pieces
of that interface that are not part of the tauri crate itself, split in two Cargo
features:
build: helpers for the pluginbuild.rs.Builderchecks the crate against the Tauri plugin conventions (thelinkskey must be set and match the crate name, the name cannot contain underscores or be a reserved one), autogenerates theallow-$command/deny-$commandpermissions for the plugin commands, parses the permission files, generates their JSON schema and reference documentation, defines the global scope schema and links the Android/iOS projects of the plugin.plugin_configreads the plugin configuration the Tauri CLI forwards to the build script, and themobilemodule has helpers to patch the generated iOSInfo.plistand entitlements and the Android manifest.runtime: reserved for the runtime side of the plugin interface. It currently exports nothing - usetauri::pluginto define the plugin itself.
§Examples
A typical plugin build.rs:
ⓘ
const COMMANDS: &[&str] = &["ping", "execute"];
fn main() {
tauri_plugin::Builder::new(COMMANDS)
.android_path("android")
.ios_path("ios")
.build();
}With a configuration type and an iOS Info.plist change:
ⓘ
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct Config {
camera_usage_description: Option<String>,
}
fn main() {
if let Some(config) = tauri_plugin::plugin_config::<Config>("my-plugin") {
if let Some(description) = config.camera_usage_description {
tauri_plugin::mobile::update_info_plist(|plist| {
plist.insert("NSCameraUsageDescription".into(), description.into());
})
.expect("failed to update Info.plist");
}
}
tauri_plugin::Builder::new(&["take_picture"]).build();
}Modules§
- mobile
build - Mobile-specific build utilities.
Structs§
- Builder
build - Builder of the Tauri plugin build script.
Functions§
- plugin_
config build - Reads the configuration of the plugin with the given name from the environment.