tauri2.0版本开辟苹果ios和安卓android应用,环境搭建和最后编译为apk ...

打印 上一主题 下一主题

主题 902|帖子 902|积分 2706



官网链接:What is Tauri? | Tauri 


初始准备

rust版本一定要1.77.2以上的版本,检察版本和升级版本:

升级命名:
  1. rustup update
复制代码
 不然会报错:
   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 **
  
创建项目
  1. npm create tauri-app@latest
  2. 然后输入项目相关信息。
  3. 进入新创建的项目
  4. 初始化环境:
  5. pnpm install
  6. android开发:
  7. pnpm tauri android init
  8. pnpm tauri android dev
  9. ios开发:
  10. pnpm tauri ios init
  11. pnpm tauri ios dev
  12. 桌面端开发:
  13. 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!
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

傲渊山岳

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表