To install CocoaPods on a Mac with an M1, M2, M3, M4 chip (Apple Silicon, ARM architecture), the process is almost the same as on an Intel Mac, but there are a few things to keep in mind regarding Ruby compatibility and Homebrew setup. Here’s the recommended approach:
Homebrew makes managing dependencies much easier. Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"After installation, make sure Homebrew’s path is set up correctly:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"CocoaPods is a Ruby gem. macOS ships with Ruby, but it can cause permission issues. It’s safer to install your own Ruby version.
Option A: Use rbenv (recommended)
brew install rbenv ruby-build
rbenv install 3.2.2 # or latest stable Ruby
rbenv global 3.2.2Then add rbenv to your shell:
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
source ~/.zshrcOption B: Use system Ruby (not recommended, but works if you don’t want extra tools).
If you go this route, you’ll need to use sudo when installing gems.
Now install CocoaPods:
gem install cocoapodsIf you’re using rbenv, you won’t need sudo.
If you’re on system Ruby, you might need:
sudo gem install cocoapodsCheck that CocoaPods installed correctly:
pod --version-
Wrong Ruby version: If you see errors about Ruby compatibility, install via
rbenvorbrew install ruby. -
Permission errors: Usually fixed by not using the system Ruby.
-
Xcode command-line tools: Make sure they’re installed:
xcode-select --install
✅ Best Practice for Macs: Use Homebrew + rbenv to manage Ruby, then install CocoaPods via gem install cocoapods. This avoids permission issues and future-proofs your setup.