I just start a react-native project. However, this question had me for a day.
I tried all possible way to solve it. For example,
sudo gem uninstall cocoapods
rvm uninstall
brew install cocoapods
However, there is no luck for me.
I would like to point out that I can pod --version
under other path but issue occur when I try to pod
under my project path. I also tried to set rvm default version to 2.7.5 but issue still happen.
Also, I am not using Apple M1
Traceback (most recent call last):
4: from /Users/nicholas/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `<main>'
3: from /Users/nicholas/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `eval'
2: from /Users/nicholas/.rvm/gems/ruby-2.7.5/bin/pod:23:in `<main>'
1: from /Users/nicholas/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/Users/nicholas/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
4
Answers
Try running
bundle install
in the root of your project. Then either go toios
and runpod install
or usenpx pod-install
from the project root.This issue is due to the difference in your default
ruby
version and ruby version specified in Gemfile . To install multiple ruby version you have to install rvm on your system and then install multiple rub versions. after install the ruby version specified in you gem file. you have to run thebundle install
command . linkAfter this you can install run
npx pod-install
orcd ios and pod install
Bundle install
prior topod install
works.To answer Bundle Install, what happens is, when generating react native project the configuration is set to default mac gem version. If you have updated gem version on your mac the project configuration could not pick the correct gem version. thats why it throws the
can't find gem cocoapods
.by doing
Bundle install
, It will update the project config according to the mac gem version.Remove cocoapods:
Then instal again: