Skip to content

Building Your App

Build your app on your own machine for the iOS simulator, a device, Google Play, or the App Store with the laravel-mobile build command.

Introduction

When you’re ready to install your app on a device or send it to the stores, you may build it using the build command. Builds run on your own machine with Xcode or the Android SDK, so they’re free and require no account with us:

laravel-mobile build ios --simulator

laravel-mobile build android

The first time you build for a platform, the build command creates the Xcode or Gradle project in apps/mobile/gen, generates every icon size from resources/mobile/icon.png, and applies your mobile.toml. Then it runs tauri ios build or tauri android build for you, using the Tauri CLI in your project’s node_modules. You never need to open Xcode or Android Studio to get there.

Building for iOS

Native iOS builds require a Mac with Xcode. If you’re on another machine, you can still preview your app on an iPhone using laravel-mobile dev.

Building for the Simulator

Simulator builds don’t need to be signed, which makes them the quickest way to try a release build. To build for the simulator, provide the --simulator option:

laravel-mobile build ios --simulator

Once the build finishes, the command tells you where to find your app:

◆ Built Acme 1.0.0 (build 1) for iOS.
  apps/mobile/gen/apple/build/…/Acme.app
  Drag the .app onto a running simulator, or run `laravel-mobile dev ios` for live reload.

Building for Devices and the App Store

To build for a physical device or for the App Store, your app needs to be signed with your Apple Developer team. First, add your team ID to the ios section of your mobile.toml file:

mobile.tomltoml
[ios]
team_id = "ABCDE12345"

Then, build your app:

laravel-mobile build ios

When you’re ready to upload to App Store Connect and TestFlight, add the --release option. This exports an .ipa signed for App Store distribution:

laravel-mobile build ios --release

Building for Android

To build your Android app, pass android to the build command:

laravel-mobile build android

By default, you’ll receive both an APK, which you may install directly on a device, and an AAB, which Google Play requires. If you only need one of them, you may provide the --apk or --aab option:

laravel-mobile build android --aab

Building for Google Play

When you’re ready to upload to Google Play, build with the --release option:

laravel-mobile build android --release

A release build is an AAB signed with your upload key, containing only the CPU architectures listed in the release section of your mobile.toml file. Before it starts compiling, the build command checks that your upload key is in place, so a missing password fails in seconds rather than after a ten-minute build.

Your Upload Key

Google Play requires every release to be signed with the same upload key. The key lives outside your repository, in a properties file named after your app’s ID:

~/.laravel-mobile/keystores/com.acme.app.properties

If you don’t have an upload key yet, the credentials command creates one for you. It writes the keystore and its properties file, with a random password, to the folder above:

laravel-mobile credentials android create

Both files are readable only by you. The command refuses to replace an existing key, because Google Play pins the first key you upload. To see what it would create without creating anything, you may provide the --dry-run option.

Keep a backup of the keystore and its properties file somewhere safe. If you lose your upload key, you’ll need to ask Google Play support to reset it.

You never edit the Gradle project to make this work. The sync command writes the signing configuration into the generated build.gradle.kts for you, so it survives every regeneration of apps/mobile/gen.

Signing in CI

In CI, you may provide the upload key with environment variables instead. Each one overrides the matching line of the properties file:

Variable Overrides
ANDROID_KEYSTORE storeFile
ANDROID_KEYSTORE_PASSWORD storePassword
ANDROID_KEY_ALIAS keyAlias
ANDROID_KEY_PASSWORD keyPassword

Choosing Architectures

By default, a release bundle contains the aarch64 and armv7 architectures, which cover nearly every phone on Google Play. Fewer architectures mean a faster Rust build. If you need emulator architectures too, you may list them using the android_targets option:

mobile.tomltoml
[release]
android_targets = ["aarch64", "armv7", "x86_64"]

The release section also holds play_track, the Google Play track to upload to (internal by default), and testflight_groups, the TestFlight groups that receive each iOS build. The planned laravel-mobile submit command will use them; until then, they have no effect.

Building for Desktop

To package your app as an installer for the computer you’re on, run build desktop:

laravel-mobile build desktop

When it finishes, the command lists the installers it wrote. On macOS, that’s a .dmg and an .app. On Windows, it’s a .msi and a -setup.exe. On Linux, it’s a .deb, an .rpm, an .AppImage, and a PKGBUILD that installs the app on Arch Linux when you run makepkg -si in its folder. The command builds for the system you run it on, so build on each system that you ship to.

Linux menus and package managers show a one-line summary under your app’s name, and file it in a section such as Office or Finance. Package managers also list your app’s license. You may set all three under [app] in your mobile.toml file. category defaults to productivity, which macOS also uses as the app’s category, and license takes an SPDX expression such as MIT, or LicenseRef-Proprietary for a closed-source app. Without it, packages list unknown:

[app]
name = "Receipts"
description = "Keep every receipt with a photo, on the web and on your phone."
category = "finance"
license = "MIT"

Desktop apps aren’t uploaded to a store, so submit desktop explains that. If doctor --platform desktop reports a missing system WebView, it says how to install it.

Build Numbers

The App Store and Google Play reject a build number they have already seen, so every upload needs a new one. Usually, you raise app.build in your mobile.toml file before each upload:

mobile.tomltoml
[app]
version = "1.2.0"
build = 8

In CI, it’s often easier to derive the number from your pipeline. The --build-number option overrides app.build for a single build, without changing your mobile.toml file:

laravel-mobile build android --release --build-number 42

Debug Builds

Release builds, and every build without --debug, always load your server.url, so that value should be your production URL. If you would like to test a build against your local server, or inspect it with the web inspector, you may build with the --debug option:

laravel-mobile build ios --simulator --debug

Since a release build is meant for the stores, the --release option can’t be combined with --debug, --simulator, or --apk.

Inspecting the Build

If you’re curious what the build command is about to do, the --dry-run option prints each command it would run, then exits:

laravel-mobile build android --dry-run

Occasionally, you may need to pass an option straight to Tauri. Anything you place after -- is passed to tauri <platform> build untouched:

laravel-mobile build android -- --target aarch64

Uploading to the Stores

Before you upload to TestFlight, you may check that your App Store Connect key works and that your app is ready for it. The credentials ios check command signs in with your key, then checks that your app’s ID is registered to your team and has an app record in App Store Connect. It runs on any machine, and it changes nothing:

laravel-mobile credentials ios check

If a check fails, the command exits with an error and shows a fix for each one. A team ID that doesn’t match your app’s bundle ID is one example: the command tells you which team ID to set in mobile.toml.

The submit command uploads your latest release build to TestFlight or Google Play, from your own machine:

laravel-mobile submit ios

laravel-mobile submit android

Run build ios --release or build android --release first. submit uploads the newest .ipa or .aab that the build wrote. For iOS, it needs a Mac, because it uses Xcode’s altool with an App Store Connect API key, which you provide through the APPLE_API_KEY, APPLE_API_ISSUER and APPLE_API_KEY_PATH environment variables. For Android, it uses a Google Play service account key, saved at ~/.laravel-mobile/google-play.json or pointed to by GOOGLE_APPLICATION_CREDENTIALS.

Android uploads go to the track in release.play_track. If you would like to send this upload to a different track, you may provide the --track option with internal, alpha, beta or production. The --path option uploads a file you built yourself, and --dry-run prints what would be uploaded without uploading it.

Google Play keeps the releases of an app that has never been released as drafts. The first upload stays a draft until you roll it out in the Play Console, and later uploads go out on their own.

If you’d rather not run any of this yourself, cloud builds and submission are planned as optional cloud services.

Some steps can’t be automated by anyone, so it’s worth knowing them up front. You create your app’s record once by hand in App Store Connect and in the Play Console. New personal Google Play accounts must also run a closed test with 12 testers for 14 days before their first production release.

Before you submit, doctor --release checks what a store release needs: a production server.url, your upload key, the Google Play service account, a Google Play target API level of 36 or higher, your Apple team, and your App Store Connect key. It combines with --platform to check one platform:

laravel-mobile doctor --release --platform android

For each check that fails, doctor shows the fix.

Finally, build ios and build android won’t start while dev is running the app on that platform, because Tauri holds the build until dev stops. Stop dev with Ctrl+C, then build again.

Type to search…

↑↓ navigate↵ selectEsc close