官网链接:What is Tauri? | Tauri
初始准备
rust版本一定要1.77.2以上的版本,检察版本和升级版本:
升级命名:
不然会报错:
error: package `tauri-plugin-shell v2.0.2` cannot be built because it requires rustc 1.77.2 or newer, while the currently active rustc version is 1.76.0
Either upgrade to rustc 1.77.2 or newer, or use
cargo update tauri-plugin-shell@2.0.2 --precise ver
where `ver` is the latest version of `tauri-plugin-shell` supporting rustc 1.76.0
Failed to run `cargo build`: command ["cargo", "build", "--package", "mobiltauri", "--manifest-path", "/Users/song/Project/my/MobilTauri/src-tauri/Cargo.toml", "--target", "aarch64-apple-ios-sim", "--features", "tauri/rustls-tls", "--lib", "--no-default-features"] exited with code 101
Error Failed to run `cargo build`: command ["cargo", "build", "--package", "mobiltauri", "--manifest-path", "/Users/song/Project/my/MobilTauri/src-tauri/Cargo.toml", "--target", "aarch64-apple-ios-sim", "--features", "tauri/rustls-tls", "--lib", "--no-default-features"] exited with code 101
ELIFECYCLE Command failed with exit code 1.
Command PhaseScriptExecution failed with a nonzero exit code
note: Run script build phase 'Build Rust Code' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'mobiltauri_iOS' from project 'mobiltauri')
** BUILD FAILED **
创建项目
- npm create tauri-app@latest
- 然后输入项目相关信息。
- 进入新创建的项目
- 初始化环境:
- pnpm install
- android开发:
- pnpm tauri android init
- pnpm tauri android dev
- ios开发:
- pnpm tauri ios init
- pnpm tauri ios dev
- 桌面端开发:
- pnpm tauri dev
复制代码
常见错误
ios要给项目分配ios开辟者id:
/Users/song/Project/my/MobilTauri/src-tauri/gen/apple/mobiltauri.xcodeproj: error: Signing for "mobiltauri_iOS" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'mobiltauri_iOS' from project 'mobiltauri')
note: Run script build phase 'Build Rust Code' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'mobiltauri_iOS' from project 'mobiltauri')
** BUILD FAILED **
command ["xcodebuild"] exited with code 65
Error command ["xcodebuild"] exited with code 65
ELIFECYCLE Command failed with exit code 1.
song$ pnpm tauri ios dev
打开src-tauri/gen/apple路径,使用xcode打开,然后在设置里面设置开辟者账号:
开辟者账号和证书不要有逾期的,不然就会报错。
运行后的效果:
android安装报错:
action request: to initialize Android environment; Android support won't be usable until you fix the issue
below and re-run `tauri android init`!
Have you installed the NDK? The `NDK_HOME` environment variable isn't set, and is required: environment
variable not found
victory: Project generated successfully!
Make cool apps! |