The annoying Cocoapods error - A troubleshooting guide
I lost count of how many times I encountered a Cocoapods error whenever I build a Flutter app for iOS or macOS, especially through VS Code. It looks like this:
Warning: CocoaPods is installed but broken. Skipping pod install.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.
To re-install:
sudo gem install cocoapods
CocoaPods not installed or not in valid state.
The error message looks almost the same, even sometimes it was due to different reasons. I will share a couple ways that worked for me:
Try to exit VS Code completely (not just reload) and start again, sometimes this is all it needs to work.
Otherwise, uninstall the Flutter extension, reload, reinstall the Flutter extension, reload again.
If it still does not work, uninstall Cocoapods by
sudo gem uninstall cocoapods
, then install again withsudo gem install cocoapods
. Make sure you only have one version of Cocoapods installed.Sometimes it is because of incompatible dependencies in your
Podfile
. In that case deletePodfile.lock
, then runpod install --repo-update
in theios
directory of your Flutter project.
Hope this helps. I'm sure the future me will also visit this page from time to time ๐