How It Works
The cache service works by:- Hashing each target based on its source files, dependencies, and build settings
- Checking if a cached binary exists for that hash
- Downloading the cached binary if available, or building and uploading if not
- Replacing source targets with their cached binaries in your Xcode project
Prerequisites
Before using the cache:- Authenticate with Tuist Cloud
- Configure your project in
Config.swift
Config.swift
Warming the Cache
Thetuist cache warm command builds targets and uploads them to the cache:
Cache Specific Targets
Cache only specific targets and their dependencies:Cache Only Dependencies
Cache dependencies without caching the specified targets:MyApp but want to cache its dependencies.
Using a Specific Configuration
Cache using a specific build configuration:By default, Tuist caches using the Debug configuration. Use Release configuration for production CI pipelines.
Using Cached Binaries
When you generate your project, Tuist automatically uses cached binaries:Cache in CI/CD
Integrate caching into your CI pipeline to speed up builds:.github/workflows/build.yml
Branch-Based Caching
Cache is automatically scoped by:- Project configuration
- Git branch
- Target hashes
Cache Configuration
Customize cache behavior in yourConfig.swift:
Config.swift
Cache Profiles
Cache profiles allow you to maintain separate caches for different build configurations:Checking Cache Configuration
View your current cache configuration:- Cache storage location
- Configured profiles
- Server connection status
Cache Operations
Check if a Target is Cached
You can check if specific targets have cached versions available without building:Print Cache Hashes
View the cache hashes for all cacheable targets:- Debugging cache misses
- Understanding what triggers cache invalidation
- Verifying cache configuration
Understanding Cache Hits and Misses
What Invalidates the Cache?
The cache for a target is invalidated when:- Source files change
- Build settings are modified
- Dependencies are updated
- Xcode version changes (by default)
- SDK version changes
Maximizing Cache Hits
To get the most out of caching:- Modularize your project: Smaller targets cache independently
- Stable dependencies: Keep third-party dependencies on fixed versions
- Consistent build settings: Avoid configuration-specific customizations
- Team alignment: Ensure everyone uses the same Xcode version
Cache Storage
Cached artifacts are stored in:- Remote: Tuist Cloud (S3-compatible storage)
- Local:
~/.tuist/Cacheon your machine
Storage Locations
Cache Analytics
Cache usage metrics are automatically sent to Tuist Cloud (if enabled), providing insights into:- Cache hit/miss rates
- Build time savings
- Storage usage
- Most frequently cached targets
View cache insights
Analyze cache performance in the Insights dashboard
Advanced Usage
Content-Addressable Storage (CAS)
Tuist uses content-addressable storage for caching, which:- Deduplicates identical files across targets
- Enables partial cache downloads
- Optimizes storage efficiency
Selective Testing with Cache
Use cache data to run only tests affected by your changes:Learn about selective testing
Discover how to speed up test runs
Troubleshooting
Cache Always Misses
If you’re experiencing constant cache misses:- Check that everyone uses the same Xcode version
- Verify build settings are consistent
- Ensure
.tuist-versionis committed - Run
tuist hash cacheto inspect target hashes
Build Fails with Cached Binaries
If a build fails when using cached binaries:Slow Cache Downloads
If cache downloads are slow:- Check your network connection
- Verify server location is geographically close
- Consider self-hosting for better performance
Best Practices
Warm cache on main branch regularly
Warm cache on main branch regularly
Set up CI to warm the cache after every merge to main. This ensures developers always have recent cached artifacts.
Use cache profiles for different scenarios
Use cache profiles for different scenarios
Create separate profiles for simulator vs device builds, debug vs release, etc.
Monitor cache hit rates
Monitor cache hit rates
Track cache hit rates in the Insights dashboard to identify optimization opportunities.
Keep dependencies stable
Keep dependencies stable
Lock third-party dependency versions to maximize cache reuse across the team.
Next Steps
Selective Testing
Use cache data to run only affected tests
Build Insights
Analyze cache performance and build metrics