Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3597d0d
feat: ACI-3938 Activate xcode step
zsolt-marta-bitrise Aug 28, 2025
82b7762
fix: ACI-3938 lint
zsolt-marta-bitrise Aug 28, 2025
b7ce728
fix: ACI-3938 Commit
zsolt-marta-bitrise Aug 28, 2025
31710dd
fix: ACI-3938 Only mac
zsolt-marta-bitrise Aug 28, 2025
16308a2
feat: ACI-3938 Log
zsolt-marta-bitrise Aug 28, 2025
c3a56cf
feat: ACI-3938 Always gather info
zsolt-marta-bitrise Aug 28, 2025
288f207
feat: ACI-3938 Always gather info
zsolt-marta-bitrise Aug 28, 2025
0a183f2
feat: ACI-3938 Build signal
zsolt-marta-bitrise Aug 29, 2025
994fd96
fix: ACI-3938 Deps
zsolt-marta-bitrise Aug 29, 2025
2e26647
fix: ACI-3938 Deps
zsolt-marta-bitrise Aug 29, 2025
eb56c2b
fix: ACI-3938 Remove xcpretty
zsolt-marta-bitrise Aug 29, 2025
24c581b
fix: ACI-3938 Remove tee
zsolt-marta-bitrise Aug 29, 2025
469da02
fix: Build test app
zsolt-marta-bitrise Aug 29, 2025
1cdf47d
fix: No need for deps
zsolt-marta-bitrise Aug 29, 2025
5f114f0
fix: branch
zsolt-marta-bitrise Aug 29, 2025
1999c73
fix: Use source
zsolt-marta-bitrise Aug 29, 2025
ea64f47
fix: Use source
zsolt-marta-bitrise Aug 29, 2025
3e97864
fix: print xcodebuild location
zsolt-marta-bitrise Aug 29, 2025
c571783
tmp: alias manually
zsolt-marta-bitrise Aug 29, 2025
ce8d5f4
tmp: alias manually
zsolt-marta-bitrise Aug 29, 2025
825deae
tmp: ls bin folder
zsolt-marta-bitrise Aug 29, 2025
b21605c
tmp: move to cli
zsolt-marta-bitrise Aug 29, 2025
12043c3
fix: Revert manual alias, add path to envman
zsolt-marta-bitrise Aug 29, 2025
ec248bc
fix: Remove manual envman
zsolt-marta-bitrise Aug 29, 2025
76929c4
fix: udpate README
zsolt-marta-bitrise Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.bitrise*
.idea
.vscode
README.md.backup
_tmp/
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# bitrise-step-xcode-enable-compilation-cache
# Bitrise Build Cache Add-On for Xcode

Enables the Bitrise Build Cache Add-On for Xcode.

## What this step does

- Configures the build using the Build Cache CLI so Bitrise Remote Build Cache is used.
- Ensures all subsequent Xcode builds in the workflow will read from the remote cache and push new entries.
- Adds a PATH entry to make the CLI available in all subsequent steps.
- From this point on, all calls to `xcodebuild` are wrapped so the underlying Xcode command has compilation caching enabled.
- The wrapper script in in `~/.bitrise-xcelerate/bin` and it's added as `xcodebuild` to the path in `~/.zshrc` and `~/.bashrc`,
- The PATH is also exported through `envman` so it's available in subsequent steps.
- Saves analytical data (command, duration, cache information, environment) to Bitrise. The data is available on the Build cache page: https://app.bitrise.io/build-cache

## Notes

- Xcode 26 Beta 4 is required to use the remote cache.
- The wrapper in the PATH persists only for subsequent steps in the current workflow run.
- Ensure your workflow uses `xcodebuild` (or compatible tooling) to benefit from the remote cache.
26 changes: 26 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
format_version: "11"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

workflows:
check:
steps:
- git::https://github.com/bitrise-steplib/steps-check.git:
inputs:
- skip_go_checks: "yes"
- workflow: lint

e2e:
steps:
- git::https://github.com/bitrise-steplib/steps-check.git:
inputs:
- workflow: e2e
- skip_go_checks: "yes"

generate_readme:
steps:
- git::https://github.com/bitrise-steplib/steps-readme-generator.git@main: { }

test_run_the_step:
steps:
- path::./:
run_if: true
100 changes: 100 additions & 0 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
format_version: "11"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/swift-package-deckofplayingcards
- BRANCH: main

workflows:
test_xcc:
after_run:
- _setup
- _run
- _check
_run:
steps:
- path::./:
title: Execute step
run_if: "true"
is_skippable: false
inputs:
- verbose: "true"
- change-workdir:
title: Switch working dir to _tmp
inputs:
- path: ./_tmp
- script:
title: build app
inputs:
- content: |-
#!/usr/bin/env bash
set -eo pipefail

if [ $(uname -s) != "Darwin" ]; then
echo "This workflow only works on macOS stack!"
exit 0
fi

echo "xcodebuild location with which: $(which xcodebuild)"
echo "xcodebuild location with type: $(type xcodebuild)"

ls -hal ~/.bitrise-xcelerate/bin/

echo "Starting build..."
xcodebuild build -destination 'generic/platform=iOS' \
-scheme DeckOfPlayingCards \
CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO -showBuildTimingSummary 2> wrapper.log > xcodebuild.log

_check:
steps:
- script:
title: gather info
is_always_run: true
inputs:
- content: |-
set -exo pipefail

cp ~/.bitrise-xcelerate/config.json $BITRISE_DEPLOY_DIR || true
cp ~/.bitrise-xcelerate/proxy.err.log $BITRISE_DEPLOY_DIR || true
cp ~/.bitrise-xcelerate/proxy.out.log $BITRISE_DEPLOY_DIR || true
cp xcodebuild.log $BITRISE_DEPLOY_DIR || true
cp wrapper.log $BITRISE_DEPLOY_DIR || true

cat "$BITRISE_DEPLOY_DIR/wrapper.log" || true
head -n 20 $BITRISE_DEPLOY_DIR/xcodebuild.log || true
tail -n 20 $BITRISE_DEPLOY_DIR/xcodebuild.log || true
- deploy-to-bitrise-io: { }
- script:
title: Check if the step is working
inputs:
- content: |-
#!/bin/bash
set -ex

if [ $(uname -s) != "Darwin" ]; then
echo "This workflow only works on macOS stack!"
exit 0
fi

# We need Xcode beta stack for checkign the cache and the current CI setup dos not suppor that. The CLI has comprehensive tests for this.
# Let's just check that the invocation is saved.

if grep -q "Invocation saved" wrapper.log; then
echo "xcodebuild invocation found in log"
else
echo "xcodebuild invocation NOT found in log"
exit 1
fi

_setup:
steps:
- script:
title: Delete _tmp dir
inputs:
- content: rm -rf _tmp
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git:
inputs:
- repository_url: $TEST_APP_URL
- clone_into_dir: ./_tmp
- branch: $BRANCH
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>bitrise-steplib/.github:renovate-config"
]
}
65 changes: 65 additions & 0 deletions step.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

# 'read' has to be before 'set -e'
read -r -d '' UNAVAILABLE_MESSAGE << EOF_MSG
Bitrise Build Cache is not activated in this build.

You have added the **Activate Bitrise Build Cache for Xcode** add-on step to your workflow.

However, you don't have an activate Bitrise Build Cache Trial or Subscription for the current workspace yet.

You can activate a Trial at [app.bitrise.io/build-cache](https://app.bitrise.io/build-cache),
or contact us at [support@bitrise.io](mailto:support@bitrise.io) to activate it.
EOF_MSG

set -eo pipefail

echo "Checking whether Bitrise Build Cache is activated for this workspace ..."
if [ "$BITRISEIO_BUILD_CACHE_ENABLED" != "true" ]; then
printf "\n%s\n" "$UNAVAILABLE_MESSAGE"
set -x
bitrise plugin install https://github.com/bitrise-io/bitrise-plugins-annotations.git
bitrise :annotations annotate "$UNAVAILABLE_MESSAGE" --style error || {
echo "Failed to create annotation"
exit 3
}
exit 2
fi
echo "Bitrise Build Cache is activated in this workspace, configuring the build environment ..."

# download the Bitrise Build Cache CLI
export BITRISE_BUILD_CACHE_CLI_VERSION="v1.0.0"
curl --retry 5 -m 30 -sSfL 'https://raw.githubusercontent.com/bitrise-io/bitrise-build-cache-cli/main/install/installer.sh' | sh -s -- -b /tmp/bin -d $BITRISE_BUILD_CACHE_CLI_VERSION || true

# Fall back to Artifact Registry if the download failed
if [ ! -f /tmp/bin/bitrise-build-cache ]; then
echo "Failed to download Bitrise Build Cache CLI, trying Artifact Registry ..."

version="${BITRISE_BUILD_CACHE_CLI_VERSION#v}"
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
package="bitrise-build-cache_${os}_${arch}.tar.gz"
filename="bitrise-build-cache_${version}_${os}_${arch}.tar.gz"

filepath="$package:$version:$filename"

echo "Downloading Bitrise Build Cache CLI from Artifact Registry: ${filepath}"

curl --retry 5 -m 60 -sSfL "https://artifactregistry.googleapis.com/download/v1/projects/ip-build-cache-prod/locations/us-central1/repositories/build-cache-cli-releases/files/${filepath}:download?alt=media" -o $package
tar -xzf "$package"
mkdir -p /tmp/bin
mv "bitrise-build-cache" /tmp/bin/bitrise-build-cache
rm -rf "$package"
fi

if [ ! -f /tmp/bin/bitrise-build-cache ]; then
echo "Failed to download Bitrise Build Cache CLI, exiting."
exit 1
fi

if [ "$verbose" != "true" ] && [ "$verbose" != "false" ]; then
echo "Parsing inputs failed: Verbose logging ($verbose) is not a valid option."
fi

# run the Bitrise Build Cache CLI
/tmp/bin/bitrise-build-cache activate xcode --debug="$verbose" --cache
32 changes: 32 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
title: Build Cache for Xcode
summary: Activates Bitrise Remote Build Cache add-on for subsequent Xcode builds in the workflow
description: |
This Step enables Bitrise's Build Cache Add‑On for Xcode by configuring the environment with the Build Cache CLI.

After this Step runs, Xcode builds invoked via xcodebuild in subsequent workflow steps will automatically read from the remote cache and push new entries when applicable.

The Step adds an alias to ~/.zshrc and ~/.bashrc so the wrapper is available in all following steps; from that point all xcodebuild calls are wrapped to enable compilation caching.
Analytical data (command, duration, cache information, environment) is collected and sent to Bitrise and is available on the Build cache page: https://app.bitrise.io/build-cache
website: https://github.com/bitrise-steplib/bitrise-step-activate-xcode-remote-cache
source_code_url: https://github.com/bitrise-steplib/bitrise-step-activate-xcode-remote-cache
support_url: https://github.com/bitrise-steplib/bitrise-step-activate-xcode-remote-cache

type_tags:
- utility

run_if: .IsCI
is_skippable: true

toolkit:
bash:
entry_file: step.sh

inputs:
- verbose: "false"
opts:
title: Verbose logging
summary: Enable logging additional information for troubleshooting
is_required: true
value_options:
- "true"
- "false"