The annoying Cocoapods error - A troubleshooting guide

Yong SheanYong Shean
2 min read

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:

  1. Try to exit VS Code completely (not just reload) and start again, sometimes this is all it needs to work.

  2. Otherwise, uninstall the Flutter extension, reload, reinstall the Flutter extension, reload again.

  3. If it still does not work, uninstall Cocoapods by sudo gem uninstall cocoapods , then install again with sudo gem install cocoapods . Make sure you only have one version of Cocoapods installed.

  4. Sometimes it is because of incompatible dependencies in your Podfile. In that case delete Podfile.lock , then run pod install --repo-update in the ios directory of your Flutter project.

Hope this helps. I'm sure the future me will also visit this page from time to time ๐Ÿ˜…

1
Subscribe to my newsletter

Read articles from Yong Shean directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yong Shean
Yong Shean

Google Developer Expert in Flutter & Dart ๐Ÿš€| Mobile App Development ๐Ÿ“ฑ| Tech Advocate ๐ŸŒ| Women Who Code KL Director