Tauri 是一个开源的软件开发框架,支持在 Linux、macOS、Windows、Android 和 iOS 上创建跨平台的桌面和移动应用程序。
安装
macOS
- 通过 App Store 安装 Xcode
- 安装 Rust
- 先通过 [[brew]] 安装:
brew install rustup
- 然后初始化:
rustup-init
- 先通过 [[brew]] 安装:
- 安装 Node.js:
brew install node
- 移动端配置 [[iOS]] (非必须)
- 把 iOS 添加为编译目标:
rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
- 安装 Cocoapods:
brew install cocoapods
- 把 iOS 添加为编译目标:
全部完成后,可以通过 [[bun]] 创建一个项目:
bun create tauri-app
下面是执行命令后:
✔ Project name · tauri-app✔ Identifier · com.immwind.tauri-app✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)✔ Choose your package manager · bun✔ Choose your UI template · Svelte - (https://svelte.dev/)✔ Choose your UI flavor · TypeScript
Template created!
Your system is missing dependencies (or they do not exist in $PATH):╭──────┬───────────────────────────────────────────────────────────────────╮│ Rust │ Visit https://www.rust-lang.org/learn/get-started#installing-rust │╰──────┴───────────────────────────────────────────────────────────────────╯
Make sure you have installed the prerequisites for your OS: https://tauri.app/start/prerequisites/, then run: cd tauri-app bun install bun run tauri android init bun run tauri ios init
For Desktop development, run: bun run tauri dev
For Android development, run: bun run tauri android dev
For iOS development, run: bun run tauri ios dev
问题
failed to run ‘cargo metadata’ command to get workspace directory: No such file or directory (os error 2) Error failed to run ‘cargo metadata’ command to get workspace directory: No such file or directory (os error 2) error: script “tauri” exited with code 1
步骤二的 Rust 没有安装导致。