Repository navigation
Build caching: Swift packages, pub cache, Bitrise caches, opt-in ccache - #32
Open
Interlap01 wants to merge 7 commits into
Open
Interlap01 wants to merge 7 commits into
Interlap01 wants to merge 7 commits into
Conversation
The runners read the opt-in ccache switch from builder.json in the snapshot; without a field for it, any command that rewrites the file would drop it.
Swift packages are cloned into ~/.ios-builder/SourcePackages with -clonedSourcePackagesDirPath on every xcodebuild that resolves the package graph, and cached on the workspace/project Package.resolved. The pub cache gets a step of its own with a fallback key, and ccache is opt-in for React Native and Expo through cache.ccache. ios-share now restores Pods, node_modules, Swift packages, the pub cache and ccache too, and saves them before the share step. The device DerivedData prefix becomes deriveddata-device-, since deriveddata- also matched the simulator workflow's caches.
… cache paths runner.sh clones Swift packages into the same directory as the GitHub workflows and carries the shared ccache block; Codemagic caches both paths.
restore-cache/save-cache for DerivedData, Swift packages, Pods, node_modules, the pub cache, Gradle and ccache. The keys checksum the snapshot's lockfiles, so the snapshot is checked out in a step of its own before the restores. An exact node_modules hit skips the install, and ios-share saves before the share step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
~/.ios-builder/SourcePackages(-clonedSourcePackagesDirPathon every xcodebuild that passes-derivedDataPath, and on theapply_build_numbercalls). GitHub caches it keyed on the workspace/projectPackage.resolved(excluding DerivedData, node_modules, Pods); Codemagic caches the path. StaleDerivedData/SourcePackagesfrom older runs is deleted before the DerivedData save.pubspec.lockwith a prefix fallback; flutter-action runs withpub-cache: false(its own pub cache had no fallback key).cache-primary-key).restore-cache@3/save-cache@1for DerivedData, Swift packages, Pods, node_modules, pub cache, Gradle and ccache. Keys checksum the snapshot's lockfiles, so the snapshot is checked out in its own step (runner.sh checkout) before the restores. The node_modulesBITRISE_CACHE_HITis aliased so an exact hit skips the install, as on GitHub. Only the per-build DerivedData/ccache saves run after a failed build."cache": {"ccache": true}in builder.json, React Native and Expo only. A shared shell block (identical in both GitHub templates and runner.sh) installs ccache and setsUSE_CCACHE=1/CCACHE_DIRbeforepod install.~/.ccacheis cached on all three providers.deriveddata-device-:deriveddata-also matched the simulator workflow'sderiveddata-sim-*caches.Why ccache is opt-in
A fresh checkout gives every file a new mtime, so a restored DerivedData still recompiles React Native and its native modules. ccache matches on content, so it helps there. But the Podfile decides whether clang goes through it: React Native's
react_native_post_installreadsUSE_CCACHE, and Expo's generated Podfile readsapple.ccacheEnabledfromPodfile.properties.json. A project whose Podfile does neither gains nothing, and installing ccache costs time on every run. Native, Flutter and KMP ignore the switch.Tests
internal/workflow/cache_test.go:cache/restorehas a save for the same paths and a key it can find again, and in ios-share that save comes before the share step-derivedDataPathalso passes-clonedSourcePackagesDirPathpod installcache.ccache.go test -race ./...,go vet ./...andgofmt -l .are clean. golangci-lint could not run locally (the installed binary was built with Go 1.25 and the module needs 1.26). actionlint is clean on both GitHub templates. Nothing was run against a real CI provider.Left out
-clonedSourcePackagesDirPathonxcodebuild -list, which detects the scheme. I did not confirm that-listaccepts the flag, so that call still resolves packages into the default DerivedData.flutter build iosresolves its own Swift packages. Only the signed Flutter archive uses the cached directory.builder init --provider bitriseto get the newbitrise.yml.