In our Podfile, we use CI
environment variable to decide whether to install certain development-only Pods (mainly Flipper). e.g.
if !ENV['CI']
use_flipper!()
end
post_install do |installer|
if !ENV['CI']
flipper_post_install(installer)
end
... etc
This seems to be the recommended approach by Flipper/React Native.
When we run pod install locally, we therefore create a Podfile.lock including Flipper. On CI, Flipper is rightly excluded.
This then causes an issue trying to cache with circleCI.
- restore_cache:
key: podfile-{{ checksum "./ios/Podfile.lock" }}
- run:
name: Install iOS pods
command: |
pod install --project-directory=ios/
git --no-pager diff --exit-code ios/Podfile.lock | echo "Podfile has been generated differently in CI to the codebase. This means it won't be cached & will be expensive/slow to run each time."
- save_cache:
paths:
- ios/Pods
key: podfile-{{ checksum "./ios/Podfile.lock" }}
This will always create changes in the Podfile.lock relative to what's been checked in.
Has anyone got a sensible strategy for this situation? Is there a better checksum to use?
I've come up with a solution to this, but it's clunky so would love to know if people have better ones. I've created a new script to replace pod install:
You can then add this as a node/npm script
"podinstall": "sh ./scripts/pod_install_for_ci.sh"
Assuming people use this instead of
pod install
, this would then allow us to useios/Podfile.ci.lock
as a cache key in circleCI.Downside obviously is it's slower for local dev, plus requires everyone to use this install method.