macOS Big Sur: Flutter doctor error –

When setting up Flutter for development on macOS Big Sur, you may run into the following error if you are managing Ruby using RVM and trying to install Cocoapods via Gem.

[!] Xcode - develop for iOS and macOS (Xcode 12.2)
    ✗ CocoaPods installed but not working.
        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
      To re-install CocoaPods, run:
        sudo gem install cocoapods

Flutter has an issue when RVM is being used to manage Ruby and Gem and Cocoapods is installed using Gem. It seems to detect that Cocoapods is installed but cannot properly access/execute it due to a Ruby version mismatch at execution.

To correct this I removed Cocoapods from Gem using ‘sudo gem uninstall cocoapods’ and I reinstalled Cocoapods using Brew instead:

> brew install cocoapods
> brew link --overwrite cocoapods

With that, ‘flutter doctor’ can now properly access/execute cocoapods.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)