Makepad Project Packaging Guide

Requirements for packaging a Makepad project depend on the target platform. This guide provides an overview of how to package your Makepad application for different platforms, including desktop and mobile.

DANGER

Due to the release of makepad 1.0 caused robius-packaging-commands tool currently exists resource path copy incomplete problem, it is currently recommended that you use another packaging method for application packaging and distribution.

See the This PR: https://github.com/project-robius/robius-packaging-commands/pull/1

Desktop Packaging

Use the cargo-packager tool to package your Makepad application.

Before you start packaging your Makepad application, make sure you already install the cargo-packager tool:

1cargo install cargo-packager --locked

This tool helps you create packages for your Makepad application, including generating the necessary files and directories for different platforms.

Then configure your Cargo.toml file to include the necessary metadata for packaging, also you can create a packager.toml file to specify additional packaging options.

This Guide use Cargo.toml as an example, but you can also use packager.toml to specify packaging options.

1[package.metadata.packager]
2product_name = "YourAppName"
3identifier = "com.yourcompany.yourapp"
4authors = ["Your Name or Team name"]
5description = "A brief description of your Makepad application"
6### Note: there is an 80-character max for each line of the `long_description`.
7long_description = "..."
8icons = ["./assets/icon.png"]
9out_dir = "./dist"
10# ... other packaging options, see the documentation for cargo-packager for more details.
11
12before-packaging-command = """
13robius-packaging-commands before-packaging \
14    --force-makepad \
15    --binary-name <main-binary-name> \
16    --path-to-binary ./target/release/<main-binary-name>
17"""
18
19# we need to specify the resources that will be included in the package, the packager will copy them to the output directory.
20resources = [
21  { src = "./dist/resources/makepad_widgets", target = "makepad_widgets" },
22  { src = "./dist/resources/your_app_name", target = "your_app_name" },
23]
24
25before-each-package-command = """
26robius-packaging-commands before-each-package \
27    --force-makepad \
28    --binary-name <main-binary-name> \
29    --path-to-binary ./target/release/<main-binary-name> \
30"""

And we use the small robius-packaging-commands CLI tool to run the packaging commands before packaging your Makepad application.

You can install the robius-packaging-commands tool using the following command:

1cargo install --locked --git https://github.com/project-robius/robius-packaging-commands.git

If you don't want to use the robius-packaging-commands tool, you can also run the packaging commands manually, but it is recommended to use the tool for convenience. and manually copy the resources to the output directory.

Such as:

1[package.metadata.packager]
2
3before-packaging-command = """
4cargo run --manifest-path packaging/before-packaging-command/Cargo.toml before-packaging
5"""
6
7before-each-package-command = """
8cargo run --manifest-path packaging/before-packaging-command/Cargo.toml before-each-package
9"""

before-packaging-command

The below command primarily uses cargo-metadata to determine the path of the makepad_widgets crate on the host build system,and copies the makepad-widgets/resources directory to the ./dist/resources/makepad_widgets directory.

We also copy the your app project's resources/ directory to the ./dist/resources/<main-binary-name> directory.

This is necessary because the cargo packager command only supports defining resources at a known path (see the resources = [...] block below),so we need to copy the resources to a known fixed (static) path before packaging, such that cargo-packager can locate them and include them in the final package.

before-each-package-command

We then build the entire your app project and set the MAKEPAD/MAKEPAD_PACKAGE_DIR env vars to the proper value.

For macOS app bundles, this should be set to . because we set the apple_bundle cfg option for Makepad, which causes Makepad to look for resources in the Contents/Resources/ directory, which is where the resources are located for an Apple app bundle (.app and .dmg).

For Debian .deb packages, this should be set to /usr/lib/<main-binary-name>, which is currently /usr/lib/<main-binary-name>. This is the directory in which dpkg copies app resource files to when installing the .deb package.

On Linux, we also strip the binaries of unneeded content, as required for Debian packages.

For Debian and Pacman (still a to-do!) packages, we also auto-generate the list of dependencies required by your application.

See more about cargo-packager: https://github.com/crabnebula-dev/cargo-packager

Linux (Debian/Ubuntu)

  1. install necessary dependencies for packaging:

    1sudo apt-get update
    2 sudo apt-get install libssl-dev libsqlite3-dev pkg-config binfmt-support libxcursor-dev libx11-dev libasound2-dev libpulse-dev
  2. run the packaging command:

    1cargo packager --release

Windows(Windows-2022)

if you already configure your Cargo.toml file as described above, you can run the packaging command:

1cargo packager --release --formats nsis

MacOS

if you already configure your Cargo.toml file as described above, you can run the packaging command:

1cargo packager --release

Mobile Packaging

Luckly, Makepad provides a convenient way to package your app for mobile platforms using cargo-makepad.

1cargo install --force --git https://github.com/makepad/makepad.git --branch dev cargo-makepad

Android

Android can easyly be packaged using cargo-makepad:

1cargo makepad android install-toolchain
2carog makepad android build -p your_profile_name -release # it will build the apk, then you can install it on your device or emulator.

iOS

1cargo makepad apple ios install-toolchain

use cargo-makepad to build the iOS app:

1cargo makepad apple ios --org=organisation_name --app=product_name run-sim/run-device -p your_profile_name --release
2
3in order for makepad to be able to install an ios application on a real device a provisioning profile is needed. 
4To create one make an empty application in xcode and give it an organisation
5name and product name you copy exactly and without spaces/odd characters into --org=x and --app=x
6                         --stable use stable compiler
7 Also run it on the device it at least once, so the profile is created
8                         --org=organisation_name
9                         --app=product_name
10 If you have multiple signing identities or devices or provision profiles you might have to set it explicitly
11                         --profile=
12                         --cert=
13                         --device=