Skip to content
Latchkey

How to Cache CocoaPods in GitHub Actions

Cache the Pods directory keyed on Podfile.lock so an unchanged dependency set restores instantly instead of re-running pod install.

Cache Pods and ~/.cocoapods keyed on a hash of Podfile.lock. On a hit, pod install --deployment is a fast no-op verification; on a miss it installs and repopulates the cache.

Steps

  • Commit Podfile.lock so the cache key is stable.
  • Cache Pods and ~/.cocoapods keyed on Podfile.lock.
  • Run pod install --deployment after the restore.

Workflow

.github/workflows/ci.yml
steps:
  - uses: actions/checkout@v4
  - uses: actions/cache@v4
    with:
      path: |
        Pods
        ~/.cocoapods
      key: pods-${{ runner.os }}-${{ hashFiles('Podfile.lock') }}
      restore-keys: pods-${{ runner.os }}-
  - run: pod install --deployment

Gotchas

  • --deployment fails the build if Podfile.lock is out of sync, catching uncommitted Pod changes.
  • If you cache ~/.cocoapods you can usually skip pod repo update, which is the slowest part.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →