Hola hola,
When working with a bare CLI React Native app, I often run into issues during the pod install
command.
Currently, I’m getting this CocoaPods could not find compatible versions for pod with: when working on the React Native version of Amplinks.
Here is the error that I’m getting. Yours could be for non-firebase packages — I’ve had it happen with Sentry/Stripe/etc.
[!] CocoaPods could not find compatible versions for pod "Firebase/Analytics":
In snapshot (Podfile.lock):
Firebase/Analytics (= 11.7.0)
In Podfile:
RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`) was resolved to 21.6.1, which depends on
Firebase/Analytics (= 11.5.0)
The CLI then gives us the following message highlighting potential issues and their fix.
You have either:
- out-of-date source repos which you can update with
pod repo update
or withpod install —-repo-update
. - changed the constraints of dependency
Firebase/Analytics
inside your development podRNFBAnalytics
. You should runpod update Firebase/Analytics
to apply changes you’ve made.
How to fix CocoaPods could not find compatible versions for pod?
Option 1: Run the command as it says
For me, the pod install — repo-update command somtimes work’s by itself. Note: you will have to run cd ios before running any pod ... command since it will look for a local ./Podfile . Here is an article from Gant at Infinite Red labeled Beginner’s Guide to Using CocoaPods with React Native.
Option 2: Remove some extra files/cache/etc
Other times, I have to:
- Delete derived data for the app I’m currently working on: StackOverflow
- run pod deintegrate to remove the bad Pods: StackOverflow
- Remove node_modules in root of React Native project
- Remove ios/Pods , ios/build , and ios/Podfile.lock (maybe even ./yarn.lock or package-lock.json
Summary
The React Native ←→ Xcode environment can be really taxing and can take up hours of your day. I call them config days and they can really dampen momentum.
I would recommend that you take extra time:
- To read, and then re-read, the error messages every time. Don’t try to copy and past into Google/ChatGPT right away — you’ve got to know what to look for.
- To read through documentation for these base level cli commands and the related environments - try and make sense of those StackOverflow links I shared. They might not make sense now but they will eventually.
- Learn about Pods and how they they mirror node_modules behavior but on a native iOS/Xcode/Swift/Objective C level — basic understanding will take you far.
Good luck — hope this was helpful!
Please give a follow on Twitter if you’re in the space!
— Matt
Top comments (0)