Tauri 2 capability files: limits of build-time permission scoping across desktop and mobile targets
0 reputation · 01 Oct 2023, 17:06 UTC
0 reputation · 01 Oct 2023, 17:06 UTC
I am designing the permission layout for a Tauri 2.x app that shares one codebase across desktop (Windows, macOS, Linux) and mobile (iOS, Android). The goal is a single, maintainable capability configuration that grants each plugin only what it needs, without over-privileging any target.
From the documentation, capabilities are declared in JSON files under src-tauri/capabilities/, validated at compile time, and can be scoped to specific windows. Permissions such as fs:allow-read-text-file are plugin-defined, and omitting an entry means the command simply is not available.
What is unclear to me is how far this model actually goes in practice. Some desktop-oriented permissions (raw filesystem paths, arbitrary shell execution) appear to have no real equivalent under iOS and Android sandboxing, and permission granularity for things like clipboard or notifications seems to differ per platform. I also understand there is no runtime prompt API on desktop — access is fixed at build time — while mobile OSes may still demand their own entitlement or user prompt on top of the capability file.
A single shared capability file is realistic for Tauri 2.x desktop and mobile builds only when every permission identifier is recognized by the plugin set on all targets. In practice, splitting per target is safer whenever desktop-only permissions—such as arbitrary filesystem paths or raw shell execution—are involved. Build-time validation typically rejects an unknown permission identifier for a target rather than silently dropping it, so a desktop-only permission usually fails the mobile build during capability validation. If a permission is accepted but the underlying OS API is sandboxed (for example, unrestricted filesystem paths on iOS or Android), the command compiles and then fails at runtime with a platform error. Desktop has no runtime elevation API inside the capability system; expanding access requires rebuilding and redistributing the binary.
Confirmed by Tauri 2.x design: capability files live under src-tauri/capabilities/, are validated at build time, and desktop access is fixed at build time. Mobile OSes layer their own requirements on top of Tauri capabilities—entitlements, usage-description strings, and interactive prompts—which are configured in platform project files, not in the capability JSON.
Likely but version-sensitive: whether a specific desktop permission is rejected by mobile validation or merely becomes a no-op depends on the plugin's permission set and the exact Tauri 2 minor release. The capability schema field used for platform scoping has shifted across versions, so confirm the current field name before relying on it.
NS*UsageDescription keys, Android manifest permissions and runtime permission requests.Which Tauri 2 minor version and plugin set are you using? The exact platform-scoping field name and the set of mobile-rejected permissions vary by release, and that detail determines whether you can safely keep a single file or must split.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.