Skip to content

Tauri mobile template guide for apple ecosystem

Notifications You must be signed in to change notification settings

Adimac93/tauri-mobile-alpha-template

Repository files navigation

Tauri mobile alpha template

This template has a general as well as dedicated sections for linux and macOS set up.

I've made a detailed step by step guide on dev.to covering particular macOS set up steps https://dev.to/adimac93/tauri-mobile-for-ios-4dp6

Warning

Tauri mobile is currently in alpha state. Please be aware that breaking changes may happen, thus making the newest version incompatible with previous ones. I'll try to do my best to keep this template up to date.

General

Install Tauri CLI.

cargo install tauri-cli --version "^2.0.0-alpha"

We also are using pnpm, so have that installed too, or use npm:

npm install -g pnpm

Clone this repository or use the Github template feature. then, cd into the project directory to perform the following steps:

Download project dependencies:

pnpm i

Run tauri dev to compile dependencies and verify that the app will run locally, before attempting to run on mobile.

cargo tauri dev

Linux + Android

Prerequisites

Follow the Tauri mobile guide on setting up linux

Development

Android codegen.

cargo tauri android init

To run the app using an android emulator, run the following (make sure you do not have a physical android phone plugged in):

cargo tauri android dev

Alternatively you can create a release build and copy it to your phone:

cargo tauri android build

this will create an apk file here:

~/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk

this file needs to be signed. you first need to generate a keystore file. Just put in whatever you want during the prompts:

keytool -genkey -v -keystore release-keystore.jks -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

I moved the release-keystore.jks file to src-tauri/gen/android/, though not required. Then you can use that file to sign your app, note that you will need to point to the apksigner that you installed with Android Studio in the prerequsite steps. you will also need to provide the absolute path to the apk file generated by cargo tauri android build:

...../Android/Sdk/build-tools/34.0.0/apksigner sign --ks /home/casey/Documents/tauri/tauri-mobile-android/src-tauri/gen/android/release-keystore.jks ...../src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk

now plug in your android phone to your computer, allow file transfer, allow the ability to install apps from the file manager, and cut through all the security warnings to install your app!

MacOS + iOS

Prerequisites

XCode

Downloads

Newest stable XCode: XCode 14.3.1 download

XCode CLI tools:

$ xcode-select --install

If you have other XCode CLI tools installed, make sure to set the correct version in XCode.

XCode > Settings > Locations > Command Line Tools > [latest stable version]

Set up

To enable application signing and testing directly on your mobile device you have to add Apple ID to XCode.

XCode > Settings... > Account > + > Apple ID

Running dev server

If you don't have any mobile device connected you can run this command and choose simulation device.

src-tauri$ cargo tauri ios dev
Running on mobile device
  1. iPhone Settings > Privacy & Security, scroll down to the Developer Mode list item and navigate into it. Then reboot your phone.
  2. Connect your phone to your MacOS device with cable.
  3. Open XCode project and open run device selection list Manage Run Destinations > + > <your phone>
  4. Run cargo tauri ios dev - the application should be copied to your phone.
  5. iPhone `Settings > VPN & Device Management > trust developer
  6. Run the application

Important

After opening the project in XCode some settings generated by cargo tauri ios init might be overwritten (especially after accepting recommended project changes).

$ cargo tauri ios open

To fix these issues (PhaseScriptExecution failed with code 65) make sure to set up back correct bundle identifier from src-tauri/tauri.conf.json and the development team (usually position with your Apple ID username). To find these settings double click on .xcodeproj file in XCode file explorer and go to Signing & Capabilities.

If you don't care about your XCode tweaks, you can always remove src-tauri/gen/apple and rerun cargo tauri ios init.

Contact

If you have any questions, contact me via discord adimac93.