Cocoapods cannot load such file LoadError - ios

I recently upgraded to Xcode 6.2 and OSX 10.10 and now adding a pod to my project doesn't work. I get the following error:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError)
I've tried all the fixes listed in this related question for Ruby 1.8 (Cocoapods No such file to load Error) and I'm still getting the same error.
I've also tried everything from this issue:
https://github.com/CocoaPods/CocoaPods/issues/2219
Things I've tried:
sudo gem uninstall xcodeproj
sudo gem uninstall cocoapods
sudo gem install xcodeproj
sudo gem install cocoapods
If I go to Xcode > Preferences > Locations > Command Line Tools: I only have an option for Xcode 6.2, so some places say to set this to Xcode 6.0, but I don't have this option.
Any help appreciated, thanks!

I had forgotten to add the following to the top of the podfile.
source 'https://github.com/CocoaPods/Specs.git'
In case someone else makes this oversight and comes across this page, hopefully this will be of help.

Related

How to setup cocoapods?

I installed cocoapods for an iOS project, but when I wrote this command pod setup --verbose nothing happened, so I tried some other code but it got worse, and now when I setup cocoapods I get this error:
/Library/Ruby/Site/2.3.0/rubygems.rb:275:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.3.0/rubygems.rb:252:in `bin_path'
from /usr/local/bin/pod:22:in `<main>'
I don't know what happened, but the usual procedure of installing Cocoapods and setting it up is as follows:
Installing Cocoapods
Open Terminal
Type sudo gem install cocoapods
Type your password and wait for it to finish
Initializing Xcode project for Cocoapods
In terminal, switch to your project's directory using the cd command
Type pod init. This will add a Podfile to your project, which you can open and add the pods you want.
Type pod install. This will also generate a .xcworkspace file along with your .xcodeproj file, and you should always use the former from now on.
With your situation where it seems like pod was either not installed or not installed properly, I suggest you try sudo gem uninstall cocoapods first to remove everything that might be present, then follow the steps above. Also, if that fails, please check that you have the lastest version of Ruby installed.

XCode: 'pod init' failing with ruby json "incompatible library version" error

I created a new XCode project and ran pod init at where that project exitsts. I got the following error.
/Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in `require': incompatible library version - /Users/xxx/.rvm/gems/ruby-2.3.0/gems/json-2.0.2/lib/json/ext/parser.bundle (fatal)
I didn't make any modification to my project. Where is the error coming from? It seems like it's coming from ruby, but it's weird to have a ruby error on a XCode project. Does anyone know how to solve this?
Thanks,
Seems like an issue with your Cocoapods installation, try uninstalling and reinstalling it.
Uninstalling
gem uninstall cocoapods
gem uninstall cocoapods-core
gem uninstall cocoapods-downloader
Reinstalling
gem install cocoapods

How to find if cocoaPods is installed in my mac

Can anyone help to find if cocoaPod is installed in my machine. I was trying to use Google Map in my application. So i was asked to install CocoaPods. Could any one help me explain me the purpose.
try to find pod version by running this in terminal
pod --version
If command not found then you didn't installed
To install cocoapods
sudo gem install cocoapods
Reference : https://cocoapods.org
Solution found: Initially the Cocoapods has to be installed using the command sudo gem install cocoapods (I had some problem with proxies so it dint work for me initially and i resolved it).
To find if Cocoapods is installed or not run cmd (pod --version). if theresult is (Not Found) Pods is not installed. Please check for the internet connection and their proxies, these things took me huge time.
Enter this line and see if you get error:
pod search realm

Cocoapods use_frameworks! issue

I found out that the way to resolve an issue, in a library i'm using, is to add use_frameworks! to the podfile. When i run pod install on the terminal, i get the following error:
[!] Invalid Podfile file: undefined method `use_frameworks!' for #.
Updating CocoaPods might fix the issue.
I'm using Cocoapods so i don't understand this issue. This tag is required for projects using swift, i'm using objective-c.
Looks to me like the second part of that error message:
Updating CocoaPods might fix the issue.
Is your issue. use_frameworks! was added in CocoaPods 0.36.0 which was just released recently.
Use pod --version to see what you're currently running. Assuming it's earlier than 0.36.0 you'll need to update it with
[sudo] gem install cocoapods
Which is just the same way you originally installed it.
I had the same issue when trying to run pod install on my mac.
So incase anyone encounters this issue what worked for me was changing the current ruby version with rvm.
On console, Use rvm list to see what versions you have installed:
So the version of ruby that was running on my mac was ruby-2.1.2.
I changed it with:
rvm use ruby-2.2.2
and ran pod install again and it worked.

Cocoa Pods need to completely re-install

The Background
I am somewhat new to Unix coming from a .NET environment but I know enough now to get me in trouble.
I got an existing code I am working with that uses Cocoapods so I tried to install Cocoapods.
Initially when I installed it it failed saying it requires a newer version of Ruby.
To install Ruby I used an installer called rvm. With some effort I got RVM installed and got Ruby Version 2.1.0.
When I go to directory where the app is and i type pod install it responds with pod: command not found. The assumption is that there must be something wrong with the install of cocoa pods. If I try any command to install or uninstall Cocoapods
gem install cocoapods or gem uninstall cocoa pods
it returns the same response which is:
/Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:59:in `gem': uninitialized constant Gem::LOADED_SPECS_MUTEX (NameError)
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:46:in `require'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems.rb:601:in `load_yaml'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:328:in `load_file'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/bin/gem:21:in `<main>'
I am thinking that perhaps the failed attempts to install cocoa pods may have either corrupted something, put something in the wrong place. I want to completely uninstall cocoapods and reinstall it but install and uninstall are not doing anything.
UPDATE: Using gem list --local | grep cocoa pods just to see what version of CocoaPods I have installed gives me the same exact output.
The Question:
Does anyone know a way to either fix this issue or completely rip and rebuild CocoaPods?
I was brilliantly assisted with help from #Pedros (the currently accepted answer) but because there were so many comments back and forth I decided to clean up the answer that worked for me. I will keep his as the accepted answer since he really helped me tremendously on this one. If this is helpful to you and you choose to up vote, please also up vote the accepted answer since this is derived almost completely from his answer.
Here is what I found out :
In my case it was that RVM was not installed correctly so RubyGems wasn't installed correctly. That in turn made CocoaPods not install correctly.
To completely uninstall and remove RVM: try sudo rvm implode or you can do sudo rm -rf ~/.rvm
I did some checks to see if I had the correct versions. I will post what they should be right now but this can be different as versions keep getting updated.
ruby --version should be 2.1.2
which ruby should be the RVM ruby. (To see if there is no conflict with OSX`s ruby)
gem --version should be 2.2.2
Reinstall RVM by doing this: \curl -sSL https://get.rvm.io | bash -s stable --ruby
Reinstall CocoaPods like this: gem install cocoapods
I hope this saves someone some development hours and hair loss :)
gem env will tell you the installation path of your gems.
By the error you got on the first time you installed the gem it could be a PATH error. Maybe your gems folder is not properly set in the PATH and shell is not finding Cocoapods.
Try to print your PATH with echo $PATH and see if the - EXECUTABLE DIRECTORY: from gem env is there.
Also try gem pristine --all
If that doesn't work try to change to ruby 2.1.2 and reinstall cocoapods.
Try bundle install first, then you can run pod install again.

Resources