Skip to content

Instantly share code, notes, and snippets.

@soroushm
Last active October 4, 2025 09:29
Show Gist options
  • Select an option

  • Save soroushm/0ce136069ce7a792fd28e7f7d646fc3d to your computer and use it in GitHub Desktop.

Select an option

Save soroushm/0ce136069ce7a792fd28e7f7d646fc3d to your computer and use it in GitHub Desktop.
Install CocoaPods on a Mac

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:


🔧 Step 1: Install Homebrew (if not already installed)

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)"

🔧 Step 2: Install Ruby (via rbenv or Homebrew)

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.2

Then add rbenv to your shell:

echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
source ~/.zshrc

Option 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.


🔧 Step 3: Install CocoaPods

Now install CocoaPods:

gem install cocoapods

If you’re using rbenv, you won’t need sudo. If you’re on system Ruby, you might need:

sudo gem install cocoapods

🔧 Step 4: Verify Installation

Check that CocoaPods installed correctly:

pod --version

⚡ Common Issues on Apple Silicon (M1/M2/M3/M4)

  • Wrong Ruby version: If you see errors about Ruby compatibility, install via rbenv or brew 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.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment