ProtonMail, a renowned provider of secure email solutions, has made its Rust-based codebase publicly available through GitHub. The repository, aptly named "rust-mail," offers developers a unique opportunity to explore and contribute to the development of ProtonMail's core features. In this article, we'll delve into the intricacies of the ProtonMail ecosystem, highlighting the essential guidelines for swift app development.

Code Formatting and Conventions

Before committing any code changes, it is crucial to ensure that all Rust files are formatted according to the Cargo Fmt rules. Similarly, TOML files must be formatted using Taplo Fmt. Failure to adhere to these formatting conventions may result in your code being rejected by the Continuous Integration (CI) pipeline.

Release Process

When preparing a release for a product or crate, create a new branch with the following syntax: releases//.. Once you're ready to release, create a tag using the format -v...

For instance, if we're working on the mail-uniffi crate, the process would involve:

  • Creating a new branch: releases/mail-uniffi/0.55
  • Creating a tag: mail-uniffi/0.55
  • Bumping the version in master
  • Running the script for generating changelog
  • Creating the respective tag and pushing it
  • Notifying the Slack channel about the pipeline with a gist from the changelog
  • Merging the branch back into master (but do not delete the source branch!)
  • Notifying the Slack channel again with a gist from the changelog

Changelog Generation

To generate the changelog, use the ./scripts/changelog tool. This can be invoked using the prepared script:

`

$ pipx install uv # if needed

$ sh ./mail/mail-uniffi/scripts/gen_changelog.sh

`

When skipping commits from the changelog, add an asterisk (*) before the colon (:) in the commit message.

Building iOS and Android Frameworks

To build iOS-specific frameworks, use the proton-build-ios command. Before doing so, ensure you have chosen the desired iPhone simulator version by running:

`

xcrun simctl list

`

Save the UUID of your chosen model to an environment variable named DEVICE_ID. Then, run the following commands:

  • ./mail/mail-uniffi/ios/build-local.sh (or use proton-run-ios if you're using Nix)
  • ./mail/mail-uniffi/ios/run-local.sh (or use proton-run-ios if you're using Nix)

Rust Logs

To view Rust logs, run:

`

xcrun simctl spawn "$DEVICE_ID" log stream \

--predicate 'subsystem == "ch.protonmail.protonmail" AND category == "[Proton] Rust"' \

--style syslog

`

Alternatively, use proton-logs-ios if you're using Nix. To view all logs (not just Rust logs), run:

`

xcrun simctl spawn "$DEVICE_ID" log stream \

--predicate 'subsystem == "ch.protonmail.protonmail"' --style syslog

`

Building Android Frameworks

To build Android-specific frameworks, refer to the rust-build/README.md documentation and profile comparisons.

Regenerating 3rdparty Directory

To regenerate the 3rdparty directory, use:

`

cargo vendor --versioned-dirs --locked 3rdparty

`