Search code examples
iosrubymacoscocoapods

Cannot install Pods in iOS Project


I have been trying to update cocoapod. In between I have updated Ruby and RVM. Now when I try pod init in my new ios project, shows the following

Traceback (most recent call last):  
2: from /usr/local/bin/pod:23:in `<main>'
1: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)

I checked the following,

  1. ruby --version

    ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
    
  2. rvm list rubies

    =* ruby-2.5.1 [ x86_64 ]
    
    # => - current
    # =* - current && default
    #  * - default
    

Solution

  • Please install cocoapods into /usr/local/bin and not into /usr/bin with this command:

    sudo gem install -n /usr/local/bin cocoapods
    

    And you should remove cocoapods before reinstalling: sudo gem uninstall cocoapods