Skip to main content

Overview

Continuous Integration (CI) and Continuous Deployment (CD) are essential for maintaining code quality and automating releases. This guide covers setting up CI/CD pipelines optimized for Tuist projects.

Understanding CI/CD with Tuist

Tuist projects have specific requirements in CI:
  • Deterministic project generation: tuist generate produces consistent projects
  • Dependency resolution: tuist install must run before generation
  • Binary caching: Significantly speeds up CI builds
  • Selective testing: Reduces test execution time
Tuist’s deterministic project generation means you don’t commit .xcodeproj files. CI generates them fresh on every run.

GitHub Actions

GitHub Actions is a popular choice for iOS CI/CD.

Basic Build Workflow

.github/workflows/build.yml

Optimized Workflow with Caching

.github/workflows/optimized-build.yml
Disable caching for fork PRs to prevent unauthorized access to your cache. The example above shows how to detect forks.

Cache Warming Workflow

Warm the cache on the main branch to speed up PR builds:
.github/workflows/cache-warm.yml

Release Workflow

.github/workflows/release.yml

GitLab CI

Basic Pipeline

.gitlab-ci.yml

Bitrise

bitrise.yml Configuration

bitrise.yml

CircleCI

config.yml

.circleci/config.yml

Best Practices

Use Force Resolved Versions

Always use --force-resolved-versions on CI:
This ensures deterministic builds by using exact versions from Package.resolved.

Cache Dependencies Effectively

Cache both dependencies and Tuist’s cache:

Enable Caching for Team Members Only

Prevent forks from accessing your cache:

Set Appropriate Timeouts

Prevent jobs from hanging:

Use Selective Testing

Run only affected tests:
Selective testing can reduce test time by 10-20x on large projects.

Warm Cache on Main Branch

Ensure PR builds have warm cache:

Use Static Linking for Release Builds

Optimize release builds:

Troubleshooting

Build Fails with “No such file or directory”

Cause: Project not generated before building Solution: Ensure tuist generate runs before xcodebuild:

Dependencies Not Found

Cause: Dependencies not installed Solution: Run tuist install before generation:

Cache Not Working

Cause: Authentication failure or caching disabled Solutions:
  1. Verify authentication:
  2. Enable caching in Tuist.swift:
  3. Check environment variable:

Slow Dependency Resolution

Cause: Not using resolved versions Solution: Always use --force-resolved-versions:

Tests Timing Out

Cause: Running full test suite Solution: Use selective testing:

Code Signing Failures

Cause: Missing certificates or provisioning profiles Solutions:
  1. Use Fastlane Match for certificate management
  2. Store certificates in CI secrets
  3. Import certificates before building:

Continuous Deployment

App Store Deployment with Fastlane

Fastfile

TestFlight Deployment

Fastfile

Monitoring CI Performance

Track Build Times

Add timing to your CI:

Set Performance Goals

  • PR builds: < 10 minutes
  • Main branch builds: < 15 minutes
  • Release builds: < 30 minutes
If CI times exceed these goals, investigate caching, selective testing, and modularization.

Next Steps

Build Optimization

Speed up CI builds with caching and optimization

Project Structure

Structure projects for efficient CI builds

Manage Dependencies

Optimize dependency management for CI

Migrate from Xcode

Migrate your project to unlock CI benefits