Cannot install CocoaPods

Hi, I am new to all this and trying to get in to flutter and learn it, while going through the install process on my MacBook after running “flutter doctor” I have these errors:

[!] Android toolchain – develop for Android devices (Android SDK version 30.0.1)
✗ Android licenses not accepted. To resolve this, run: flutter doctor

[!] Xcode – develop for iOS and macOS
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side’s plugin
code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see
To install see for

I am trying to fix the cocoapods one first then I’ll move on to the Android issue, I’ve done the “sudo gem install cocoapods” command multiple times to install cocoapods but I keep errors every time. This is the full error:

Building native extensions. This could take a while…
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210328-35795-2hn7gj.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in block in try_link0′
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in mktmpdir' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in try_link0′
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in try_link' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in try_ldflags’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in pkg_config' from extconf.rb:9:in system_libffi_usable?’
from extconf.rb:42:in `

To see why this extension failed to compile, please check the mkmf.log which can be found here:


extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.15.0/gem_make.out

Also here is the attached log file:

If anyone could help me get this installed so I could move on and start using flutter that would be great thanks.

1 possible answer(s) on “Cannot install CocoaPods

  1. The gem native extension builder can’t seem to locate your Xcode developer toolchain.

    If you use Homebrew, you could try installing cocoapods via the homebrew package:

    brew install cocoapods

    Alternatively, you could try the following to ensure Xcode is properly setup in your environment:

    # Install Xcode
    sudo xcode-select --install
    # View/agree to the Xcode license
    sudo xcodebuild -license
    # Switch to the typical location for developer tools
    # (if this path doesn't exist, you can get a hint by running `clang --version` and
    # checking the `InstalledDir` field for location of the `Developer` directory)
    sudo xcode-select --switch /Applications/