Caching
How to configure caching for your builds
Caching can improve the efficiency of your build and deployment processes on Codemagic by reusing components that are generated or fetched during the build, such as packages, libraries, and compiled code.
When you have enabled caching for a workflow, Codemagic will automatically generate a cache based on the output of the first successful build. This cache is stored for a maximum of 14 days. After 14 days, the cache expires and is no longer accessible for subsequent builds. When this occurs, your workflow will fetch all dependencies and artifacts again and generate a new cache. This new cache is then uploaded and can be used for the next 14 days, following the same process.
For example, you may consider caching the following paths:
Path | Description |
---|---|
$HOME/.pub-cache | Dart cache |
$HOME/.gradle/caches | Gradle cache. Note: do not cache $HOME/.gradle |
$HOME/Library/Caches/CocoaPods | CocoaPods cache |
A great article on Unity caching can be found in our blog.
$HOME/Library/Developer/Xcode/DerivedData
won’t help to speed up iOS builds with Xcode 10.2 or later.Enabling dependency caching
To use caching, simply add a cache
section to your codemagic.yaml
file and list the paths you would like to cache.
cache:
cache_paths:
- ~/.gradle/caches
- ...
- In your app settings, open the Dependency caching section.
- Check the Enable dependency caching option. By default, caching is disabled.
- Enter the path(s) to the dependencies to be cached and click Add. Note that you can delete added paths anytime.
Cache usage limits
Maximum cache size is limited to
- 10GB per workflow for teams, and
- 3GB per workflow for personal accounts.
Note that installing dependencies without using caching could be faster than retrieving or updating cached data.
Removing cached dependencies
In order to clear the collected cache, navigate to the Dependency caching section in app settings and click Clear cache. During the next build, dependencies will be downloaded afresh.