CocoaPods Installation Failure

Hi everyone!

Recently I’ve been trying to integrate LevelPlay into my Unity project. I’ve been able to make it work on Android, but I’m having issues with iOS. LevelPlay requires CocoaPods, however when I go to the iOS Resolver / Install CocoaPods, I always get this error:

Failed to install CocoaPods for the current user.

It will not be possible to install Cocoapods in the generated Xcode project which will result in link errors when building your application.

For more information see:
  https://guides.cocoapods.org/using/getting-started.html


'gem install cocoapods --user-install --verbose' failed with code (1):
HEAD https://rubygems.org/api/v1/dependencies
404 Not Found
GET https://rubygems.org/prerelease_specs.4.8.gz
304 Not Modified
GET https://rubygems.org/specs.4.8.gz
304 Not Modified


WARNING:  You don't have /Users/arilio/.gem/ruby/2.6.0/bin in your PATH,
      gem executables will not run.
ERROR:  Error installing cocoapods:
    The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6. Try installing it with `gem install drb -v 2.0.6` and then running the current command again
    drb requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210.

I installed a newer version of Ruby via Homebrew (v3.3.2) and I’ve even successfully installed CocoaPods via the terminal in the project’s folder, yet Unity seems to recognise the preinstalled version of Ruby on MacOS (2.6.10).

I’ve tried every possible solution I came across online in forums and web articles/guides to no avail. I even found an amazing blog about the EXACT same problem I had (The fastest and easiest way to install Ruby on a Mac in 2024), followed every step and did everything successfully, yet the problem still persists.

I’m very new to terminal in MacOS and I’m still learning. I’ve just ran out of possible solutions. Any help would be appreciated. Thank you!

Ok so I managed to solve it.

- Q: Why does this happen?

  • A: Unity uses the bash shell in terminal, instead of zsh (z-shell) for some reason. zsh is the default shell in the new versions of MacOS, so when I installed Ruby, CocoaPods etc through terminal, they were installed in the zsh. So since Unity only uses the bash shell, it doesn’t recognise them.

Note that I’m new to using terminal. The explanation I gave may have some mistakes. It’s simply my understanding of the problem with CocoaPods and the macOS terminal.

In case anyone is facing the same issues here are the new steps I followed:

  1. In terminal go to Settings / General / Shells open with, and then click on Command (complete path) and replace bin/zsh with bin/bash (Use zsh as the default shell on your Mac – Apple Support (UK))
  2. Quit and Restart terminal
  3. Try to “gem install cocoapods”. It should give an error saying that you should install an older version of drb (a gem that CocoaPods depends on), so try “gem install drb -v 2.0.6
  4. Once that’s installed, if you try to install CocoaPods again it will give you another error with instructions saying that you should install activesupport v6.1.7.8, so try “gem install activesupport -v 6.1.7.8
  5. Once that’s installed finally try “gem install cocoapods” and you’re done!

Hope this is helpful

7 Likes

Hey @Arilio19, thanks for your question and solution. Your explanation makes sense. Although, I’d be hesitant to change my default shell back to bash. I ended up solving this issues by upgrading drb and activesupport in zsh but I had to sudo to update the pre-installed gems. Which I’m not a big fan of doing either. I didn’t want to go down the path of trying to get Unity to use zsh instead of bash. But I feel like that would be the “proper” way to fix this on the long run.

@Arilio19 It would be helpful if you write your macOS version and Unity version. I am facing the same error message.

Yes, this is annoying. I usually solve this issue by installing ruby via homebrew and adding the following lines to ~/.profile:

export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
export PATH="/opt/homebrew/lib/ruby/gems/3.3.0/bin:$PATH"
export PATH="$PATH:$GEM_HOME/bin"

Can you elaborate on this for me? I’m just starting with an attempt at ios deployment and all this mac stuff is new to me. I also installed ruby with homebrew, which is in the wrong location for Unity. What exactly is ~/.profile? Is that a Unity thing or a Mac thing?

EDIT: I appear to have solved my problem with the accepted answer. Some of the names of the files were changed but I went through a very similar process. I don’t mind switching to bash because this stupid mac is only for unity building.