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!
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:
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”
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”
Once that’s installed finally try “gem install cocoapods” and you’re done!
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.
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.
compile/build your iOS project as normal and ignore the failed to install CocoaPods error. once compiled, go to the folder where your project has been built.
right click on the folder, select ‘new terminal at folder’
in terminal, type:
arch -x86_64 pod install
terminal will tell you to ignore the initially constructed Xcode project folder and use the Unity-iPhone.xcworkspace (ie. double click to open in Xcode). the it opens, select unity-phone from the left panel. fill in the details for your project and signing as normal. go to project and select archive.
this is what worked for me after dicking around and trying to jump over a zillion hurdles while continually falling on my face. hope it helps someone else.
ps. you will need to do this each time you build a unity project for iOS.
None of these solutions work.
I can see pod installation in .profile, .bashrc and .zshrc but unity 6 is stupidly insisting to install cocoapods.
It tries to use built-in ruby which is outdated (2.6) and this is giving headaches.
After reading through all of these and trying it all out, switching my terminal over to bash and installing rbenv as my ruby manager I ended up adding the following to my .bash_profile file to get away from the stupid default mac ruby instance:
eval "$(rbenv init - bash)"
I added the above line to my .bash_profile before any other statement trying the set the GEM_HOME. Safe bet is to add this right at the beginning before any PATH updates happen.