ams-tauri-mobile-pro
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 0
- Forks
- 1
03 SKILL.md 正文
Tauri Mobile Pro
A practical guide to Tauri for mobile: wrapping a web frontend (any framework) with a Rust backend on iOS and Android — project setup, the command/IPC bridge, mobile plugins, permissions, and getting to the app stores.
Overview
Tauri Mobile lets you ship iOS and Android apps where the UI is your web app (HTML/CSS/JS) and privileged work happens in Rust. Compared to a pure webview wrapper, you get a real Rust backend: fine-grained capabilities, small binaries, and native APIs via plugins. Compared to Electron-style desktop Tauri, mobile adds platform permissions, app-store rules, and mobile-specific plugins (barcode scanner, biometrics, haptics).
The architecture: webview frontend ↔ IPC commands ↔ Rust backend ↔ OS APIs.
When to use
- Shipping an existing web app as iOS/Android apps with native capabilities.
- Apps needing Rust performance or security properties on mobile (crypto, local processing).
- Small binary size matters (Tauri apps are dramatically smaller than Chromium-based wrappers).
- You want one web codebase for web + desktop + mobile.
Core concepts
- Commands. Rust functions exposed to JS via
#[tauri::command]+invoke('command_name', args). Arguments serialize as JSON — keep payloads small and typed. - Capabilities. Tauri's permission system: which windows/webviews can call which commands and access which APIs. Default-deny — you explicitly allow. Scope filesystem access narrowly.
- Plugins. Official and community plugins for mobile APIs: filesystem, dialog, notification, geolocation, barcode-scanner, biometrics, haptics, share. Add via cargo + JS package.
- Mobile init.
tauri mobile initscaffolds Android (Gradle/Kotlin) and iOS (Xcode/Swift) projects inside your Tauri app. You need Android Studio / Xcode toolchains installed. - Permissions (OS-level). Camera, location, notifications require entries in
AndroidManifest.xml/Info.plistand runtime permission requests. Declare in config, request at point of use. - App identifiers. Reverse-DNS bundle IDs (
com.example.app) must match across config, stores, and signing — decide once, early. - Build flavors. Debug builds for iteration (
tauri android dev/tauri ios devwith a connected device or emulator); release builds for stores with proper signing.
Practical workflow
1. Scaffold.
npm create tauri-app@latest # or add to existing project
cd my-app
tauri mobile init # generates android/ and ios/ projects
2. Expose a command.
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
// register in Builder: .invoke_handler(tauri::generate_handler![greet])
import { invoke } from '@tauri-apps/api/core';
const msg = await invoke<string>('greet', { name: 'Ada' });
3. Add a plugin (e.g., notifications).
cargo add tauri-plugin-notification
npm i @tauri-apps/plugin-notification
Enable in capabilities JSON, request permission at runtime before first use.
4. Configure capabilities. In capabilities/*.json, allow exactly the commands and plugin APIs each window needs — e.g., the main window can call greet and notification:*, nothing else.
5. Dev loop. tauri android dev / tauri ios dev — hot-reloads the web frontend; Rust changes need rebuild. Test on real devices early: emulators hide permission and performance issues.
6. Ship. tauri android build → signed AAB; tauri ios build → archive for App Store Connect. Set up signing (keystore / Apple certificates) in CI; never commit signing secrets.
Common pitfalls
- Desktop assumptions. Code that works in Tauri desktop may fail on mobile: no multiple windows the same way, different filesystem roots, backgrounding kills webviews.
- Permission timing. Requesting all permissions at launch triggers denials. Request each permission in context, right before the feature needs it, with a clear explanation.
- Capability misconfiguration. Overly broad capabilities (
*everywhere) negate Tauri's security model; too narrow breaks features silently. Test every command path after tightening. - Blocking the UI thread. Heavy Rust work on the command handler blocks IPC responses. Spawn async tasks / threads for long work and return progress via events.
- Binary size creep. Each plugin and dependency adds weight. Audit with release builds; strip symbols, enable LTO for shipping.
- Store rejections. Apple especially: explain background modes, don't request unused permissions, follow human-interface guidelines for the webview chrome. Read rejection-prone categories (payments, data collection) before submitting.
- Hardcoded dev URLs. The dev server URL in mobile config must be reachable from the device (LAN IP, not localhost). Use the
--hostflow Tauri documents for device testing. - Ignoring lifecycle. Mobile apps suspend/resume; persist state on backgrounding and restore cleanly — users will background your app mid-task.
04 同仓库更多 Skills
web-scrape
Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.
design-taste-frontend
tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).