ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension

Published

Have you been trying to install cocoapods on your Mac and getting this “failed to build gem native extension” error?

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

This is a common issue people face when trying to install gems on a Mac that doesn’t have a proper Ruby development environment. To make things worse, the cocoapods documentation recommends using the default Ruby that comes with macOS, and to use sudo gem install cocoapods. Both of those should be avoided.

Learn why you shouldn’t use the system Ruby to install gems on a Mac and why you should never use sudo to install gems.

The correct way to install cocoapods on a Mac

While there are various ways to install gems on a Mac, there’s really only one method that should be recommended: using a version manager.

I highly recommend using a Ruby manager because it allows you to have multiple versions of Ruby installed at the same time, and makes it easy to switch between them. Even if you’re using Ruby for the first time, it’s worth your time to learn how to use a Ruby manager because you will inevitably need one.

Over the past ten years, I’ve helped thousands of people set up Ruby on their Mac. It’s my specialty. From clean Macs to the most obscure issues, I’ve seen and fixed it all. And the most reliable solution is to use a version manager, specifically chruby.

To help people like you, and to make it as easy and painless as possible, I built Ruby on Mac, an automated script that will get you up and running with cocoapods in minutes.

Read what people say about the script.

It doesn’t just have a one-time use. You can run it over and over to keep your system up to date and secure. And the next time you get a new Mac, it will save you half a day because it can also automatically install all your Mac apps, in addition to a complete development environment. You get all of these time savings now and in the future for a one-time cost.

When you buy Ruby on Mac today, you’ll be supporting an independent developer, and you get it at a very reasonable price given how much time it saves.

If you’re trying to set up cocoapods on a work computer, you should be able to expense the one-time cost of Ruby on Mac.