- Home
- Dependencies and caching
- Remote build caching
- Remote build cache for Tuist
Remote build cache for Tuist
Tuist is a command line tool that aims to facilitate the generation, maintenance, and interaction with Xcode projects. Bitrise offers a custom, hosted implementation of Tuist's remote cache feature. You can use this implementation both locally and in the Bitrise CI environment.
Tuist is a command line tool that aims to facilitate the generation, maintenance, and interaction with Xcode projects. Bitrise offers a custom, hosted implementation of Tuist's remote cache feature. You can use this implementation both locally and in our CI environment.
Configuring remote caching for Tuist in the Bitrise CI environment
To use the Tuist cache on Bitrise, you need two use two Tuist commands in your Workflows: tuist cache warm and tuist generate. We recommend using two separate Workflows for this: one Workflow for the cache warming and one Workflow for actually building with Tuist.
Workflow Editor
bitrise.yml
-
Disable Tuist Cloud in your Tuist project, if you use it. This is necessary because if Tuist Cloud is enabled, it will take precedence over the Bitrise build cache.
-
Create a new Workflow. This Workflow will run the tuist cache warm command and populate the remote cache for the first time.
It is a good practice to run this Workflow periodically to make sure the cache is warm when you run time-critical CI Workflows. For example, you can schedule a nightly run for this Workflow. The exact implementation depends on your specific requirements.
-
Add the Activate Bitrise Build Cache for Tuist Step to the Workflow.
Don't run Tuist commands before this Step
The Step must come before any Step that runs any Tuist command!
-
Add a Script Step to the Workflow.
-
In the Content input, add the following script:
tuist fetch tuist cache warm --dependencies-only
Warm with dependencies only
It’s a good practice to run the warm command with the
--dependencies-only
flag for the first time. This will only build the dependency targets, which have a smaller chance of breaking the build. Once the dependencies are cached, you can remove the flag and try building all targets. -
Now you can use the Tuist cache in other Workflows: add the Activate Bitrise Build Cache for Tuist Step to any Workflow in which you want to use the tuist generate command. The Step should come right after the Git Clone Step.
-
To run tuist generate, add a Script Step to the Workflow, and add the following to the Content input:
tuist generate MyTarget --no-open
Focused Xcode project
To get the most performance out of build avoidance and caching, don't forget to generate a focused Xcode project instead of the full project! When remote caching is enabled and you generate a focused project, Tuist replaces the dependencies of the focused target (both 3rd party and project targets) with precompiled frameworks directly from the remote cache.
-
Disable Tuist Cloud in your Tuist project, if you use it. This is necessary because if Tuist Cloud is enabled, it will take precedence over the Bitrise build cache.
-
In the
bitrise.yml
file, create a Workflow that will run the tuist cache warm command and populate the remote cache for the first time.It is a good practice to run this Workflow periodically to make sure the cache is warm when you run time-critical CI Workflows. For example, you can schedule a nightly run for this Workflow. The exact implementation depends on your specific requirements.
-
Add the
activate-build-cache-for-tuist
Step to the Workflow.Don't run Tuist commands before this Step
The Step must come before any Step that runs any Tuist command!
my_workflow: steps: - git-clone: {} - activate-build-cache-for-tuist: title: Activate Bitrise build cache for Tuist
-
Add a
script
Step to the Workflow and addtuist fetch
andtuist cache warm --dependencies only
to thecontent
input:my_workflow: steps: - git-clone: {} - activate-build-cache-for-tuist: title: Activate Bitrise build cache for Tuist - script: title: Tuist cache warm inputs: - content: |- set -ex tuist fetch tuist cache warm --dependencies-only
Warm with dependencies only
It’s a good practie to run the warm command with the
--dependencies-only
flag for the first time. This will only build the dependency targets, which have a smaller chance of breaking the build. Once the dependencies are cached, you can remove the flag and try building all targets. -
Now you can use the Tuist cache in other Workflows: add the
activate-build-cache-for-tuist
Step to any Workflow in which you want to use the tuist generate command. The Step should come right after thegit-clone
Step.my_other_workflow: steps: - git-clone: {} - activate-build-cache-for-tuist: title: Activate Bitrise build cache for Tuist
-
To run tuist generate, add a
script
Step to the Workflow, and add the generate command to thecontent
input:my_other_workflow: steps: - git-clone: {} - activate-build-cache-for-tuist: title: Activate Bitrise build cache for Tuist - script: title: Tuist generate inputs: - content: |- set -ex tuist generate MyTarget --no-open
You’ll know the cache is working when you see 🤖 Bitrise remote cache enabled
in the Tuist output.
Configure remote caching for Tuist in local builds
Remote caching in local builds allows you to use the same cache for your local builds and the Bitrise CI environment. It can minimize build times in both environments.
To configure remote caching for Tuist in local builds:
-
Disable Tuist Cloud in your Tuist project, if you use it. This is necessary because if Tuist Cloud is enabled, it will take precedence over the Bitrise build cache.
-
Set up remote caching for Tuist in the Bitrise CI environment: Configuring remote caching for Tuist in the Bitrise CI environment.
-
Install a Tuist version that supports the Bitrise build cache. You can use the following shell script to download the Tuist binary and unzip it to the project's
.tuist-bin
folder:RELEASE_URL=https://bitrise-tuist.bitrise.io/tuist-3.18-bitrise-a4baa03.zip DOWNLOAD_PATH=$TMPDIR/tuist.zip TUIST_BIN_PATH=.tuist-bin curl -s --fail --show-error $RELEASE_URL --output "$DOWNLOAD_PATH" echo "b31d9c982809a2dea0c0d7b091674bb4b9b3035d7efcb035fd1880d7284fbb88 *$DOWNLOAD_PATH" | shasum -a 256 --check rm -rf "$TUIST_BIN_PATH" mkdir "$TUIST_BIN_PATH" tar -xf "$DOWNLOAD_PATH" --directory="$TUIST_BIN_PATH"
Once this is done, calling tuist from the project root folder will use the vendored binary in
.tuist-bin
. -
Generate a Personal Access Token on Bitrise: Creating a personal access token.
-
Find your Workspace ID. You can do so by navigating to the Workspace's page and find the ID in the URL.
-
Open the project's Config.swift file and provide your Bitrise credentials.
import ProjectDescription let config = Config( // other config options... bitrise: .bitrise( workspaceId: "your-bitrise-workspace-id", authToken: Environment.bitriseAuthToken.getString(default: "") ) )
You need to:
-
Replace the
workspaceId
placeholder value with the actual Workspace ID. -
Make sure you have a local Environment Variable with the key
BITRISE_AUTH_TOKEN
that contains your personal access token. The snippet above expects that exact variable with the secret value. If your project handles secrets differently, you will need to modify the snippet to adopt your project's pattern.
-
-
Execute the usual tuist generate commands.
If the configuration is correct, you should see the line 🤖 Bitrise remote cache enabled
in the Tuist logs, as well as traces of Tuist downloading the prebuilt frameworks from the remote cache.
- Getting started with iOS apps
- Workflows
- Default Workflows
- Apple services connection
- Connecting to an Apple service with API key
- Connecting to an Apple service with Apple ID
- Connecting to a VPN during a build
- Remote build cache for Gradle
- iOS code signing
- iOS deployment
- Deploying an iOS app for external testing
- Deploying an iOS app to App Store Connect
- Managing iOS code signing files
- Managing build artifacts
A Workspace is an environment that allows you to manage your Bitrise apps and the team members working on the apps. You can create multiple Workspaces, and you can be invited to Workspaces by other Bitrise users. To be able to add apps and run builds, you either need to be part of a Workspace, or you have to be an outside contributor on an app's team.