cocoapods not installing - ios

What does it mean and how can I fix it:
pod install
/Library/Ruby/Site/2.0.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:278:in `activate_bin_path'
from /usr/local/bin/pod:22:in `<main>'

Using following commands, it worked for me.
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
cocoapods pod install
If you encounter this error on step 2:
ERROR: While executing gem ... (Gem::CommandLineError) Please specify at least one gem name (e.g. gem build GEMNAME)
Then try this as step 2 instead (step 3 is not needed):
gem install -n /usr/local/bin cocoapods

If you install cocoapod using brew like me
Reinstall cocoapods:
brew reinstall cocoapods
If you see this error message after you reinstall cocoapods by brew reinstall go to step 2.
>
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
rm '/usr/local/bin/pod'
To force the link and overwrite all conflicting files:
brew link --overwrite cocoapods
To list all files that would be deleted:
brew link --overwrite --dry-run cocoapods
Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
To solve conflicting files:
brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.3.1... 2 symlinks created

Uninstall the existing cocoapods, if any, by following command:
gem list --local | grep cocoapods | awk '{print $1}' | xargs sudo gem uninstall
Then install it to /usr/local/bin instead of /usr/bin using following command:
sudo gem install -n /usr/local/bin cocoapods
For further query, check this link to uninstall and this link to install cocoapods.

In my case nothing helped, then I:
sudo gem uninstall cocoapods
cd /Users/nikkov/.rvm/rubies/ruby-2.4.1/lib/ruby; In Finder I searched for cocoapods and removed everything.
brew install cocoapods
brew link --overwrite cocoapods (if needed)

I had upgraded my ruby version 2.5.3 to 2.7.2. Then, I want to update cocoapods from 1.9.3 to 1.10.0 . I got the following error while executing pod install.
can't find gem cocoapods (>= 0.a) with executable pod
(Gem::GemNotFoundException)
There is two way to install cocoapods by using homebrew & gem. If you had install cocoapods using gem run following.
sudo gem uninstall cocoapods
sudo gem uninstall -n /usr/local/bin cocoapods
If you had used brew please using the following to uninstall
brew uninstall cocoapods
If you forgot which one you used earlier, please execute both commands. Please make sure all cocoapods instances are removed to check run pod --version.
If you find -bash: pod: command not found as output, all instances are removed properly. Else, you may need to remove cocoapods related files manually from this directory ~/.rvm/rubies/ruby-2.5.3/lib/ruby.
sudo gem update --system
gem install cocoapods
CREDIT: https://blog.csdn.net/develop_csdn/article/details/105053383

Thankfully i found solution after a hours.
As you know, newest Mac Operation System(Big Sur or oldest one) use ruby as a version system. So this ruby is private. You can not write/update some files that belong ruby.
So, we had a change to install rbenv for as a version control.
Firstly you should install rbenv via brew if you don't have
$ brew install rbenv
You need to know rbenv version number. You can see with below code snipped
$ rbenv version
Install Xcode's command line tools
xcode-select --install
Install rbenv via Homebrew
brew update
brew install rbenv ruby-build
Configure rbenv
eval "$(rbenv init -)"
Install and configure Ruby
rbenv install 3.1.1
rbenv global 3.1.1
rbenv rehash
source ~/.bash_profile
Install Cocoapods:
gem install cocoapods

In my case the reason of the issue was Gemfile file inside the folder with the project. When I removed this file, cocoapods started functioning as usual.

Try sudo gem update
After remove cocoapods
-Install cocoapods

When I tried #Aamir's solution, I ran into the error:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (https://api.rubygems.org/specs.4.8.gz)
This worked for my Mac:
sudo gem uninstall cocoapods
sudo gem install cocoapods

What finally worked for me was running rvm reset before reinstalling cocoapods
rvm reset
rvm --version
sudo gem install -n /usr/local/bin cocoapods
from here

In my case I was not able to install pod and cocoapods using gem, after changing command line tools I was able to run the commands

Running these commands worked for me:
brew update
brew install fastlane
fastlane install_plugins

React native has made several changes and this is how you install pods now
cd ios
bundle install
bundle exec pod install
https://reactnative.dev/docs/environment-setup

This helped me after I tried all these ways
xcode-select --install

If anyone stumbles upon this as a result of updating to react native 0.67.2+ from an older version (we were on 0.66.0) you have to make sure you re-install cocoapods via gem install cocoapods. Otherwise, your pod install will not work.

I'd installed Cocoapods using gem, so I reinstalled it again using gem. nothing happened.
so I removed it and install it using brew. it works.

I have also wrote on github, so I will copy it here, maybe it will be helpful for someone.
To be honest none of those solutions worked for me, just typing randomly commands will not help.
I don't know why, but my path was misconfigured. So first you should check if the path is good. I have used brew and installed rbenv in order to use safely libraries and after I ran pod install, I saw it was not targeting the right folder and always used the system version.
After I ran command
gem env
I saw that some paths are not correct.
"INSTALLATION DIRECTORY, RUBY EXECUTABLE, EXECUTABLE DIRECTORY, SYSTEM CONFIGURATION DIRECTORY AND GEM PATH"
should start something like this(depends of version) /Users/{username}/.rbenv/versions/3.1.2/lib/ruby/. ... otherwise it uses system version..
In order to fix this you need to set paths in ~/.zshrc and ~/.zprofile
my zshrc looks like this:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH=/opt/homebrew/bin:$PATH
export RBENV_ROOT=$HOME/.rbenv
export PATH=$RBENV_ROOT/shims:/versions:$PATH
zprofile:
eval $(/opt/homebrew/bin/brew shellenv)
in order to change /.zshrc: type nano ~/.zshrc

To relink, run:
brew unlink cocoapods && brew link cocoapods

Related

Cocoapods behaving awkwardly [duplicate]

I'm having some issues installing Alamofire 4.0 into my project.
I've got the latest version of Xcode, running Swift 3, and when I try to install alamofire I'm getting like 800 compiler errors.
Apparently
CocoaPods 1.1.0+ is required to build Alamofire 4.0.0+
[!] some_cocoapod requires CocoaPods version >= X.Y.Z, which is not satisfied by your current version, Z.Y.X.
I looked at the version of CocoaPods I have in terminal and it says I'm at 1.0.1.
Running an update didn't work I guess because CocoaPods 1.1 is in beta.
So I'm not exactly sure how to update it up to where I'm good to go.
Unless being out of date doesn't force like 800 compiler errors? Does that sound like some other issue?
Execute the following on your terminal to get the latest stable version:
sudo gem install cocoapods
Add --pre to get the latest pre release:
sudo gem install cocoapods --pre
If you originally installed the cocoapods gem using sudo, you should use that command again.
Later on, when you're actively using CocoaPods by installing pods, you will be notified when new versions become available with a CocoaPods X.X.X is now available, please update message.
Open the Terminal -> copy below command
sudo gem install cocoapods
It will install the latest stable version of cocoapods.
after that, you need to update pod using below command
pod setup
You can check pod version using below command
pod --version
If you got System Integrity Protection enabled or any other permission write error, which is enabled by default since macOS Sierra release, you should update CocoaPods, running this line in terminal:
sudo gem install cocoapods -n/usr/local/bin
After installing, check your pod version:
pod --version
You will get rid of this error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory
And it will install latest CocoaPods:
Successfully installed cocoapods-x.x.x
Parsing documentation for cocoapods-x.x.x
Installing ri documentation for cocoapods-x.x.x
Done installing documentation for cocoapods after 4 seconds
1 gem installed
If you are using Homebrew, open terminal and type:
brew upgrade cocoapods
If that does not work, try:
brew install cocoapods
After that, run:
brew link --overwrite cocoapods
For those with a sudo-less CocoaPods installation (i.e., you do not want to grant RubyGems admin privileges), you don't need the sudo command to update your CocoaPods installation at all:
gem install cocoapods
You can find out where the CocoaPods gem is installed with:
gem which cocoapods
If this is within your home directory, you should definitely run gem install cocoapods without using sudo.
Finally, to check which CocoaPods you are currently running type:
pod --version
I had to do this, was stuck on 1.9.1 on macOS
sudo gem install -n /usr/local/bin cocoapods
Below are steps to update cocoapods :
Open terminal (Shortcut : Press cmd + space tab to open Spotlight then text in terminal)
Use command sudo gem install cocoapods. This will ask for system password due to security concern thereafter it installs gems
Now, set up pod using pod setup command. This will setup cocoapods master repo.
You can check the version of cocoapods using pod --version command.
Non of the above solved my problem, you can check pod version using two commands:
pod --version
gem which cocoapods
In my case pod --version always showed "1.5.0" while gem which cocopods shows
Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.0/lib/cocoapods.rb. I tried every thing but unable to update version showed from pod --version. sudo gem install cocopods result in installing latest version but pod --version always showing previous version. Finally I tried these commands:
sudo gem update
sudo gem uninstall cocoapods
sudo gem install cocoapods
pod setup``pod install
The catch for me was sudo gem update. Hopefully it will help any body else.
You can solve this problem by these Commands:
First:
sudo gem install cocoapods
Desp: type user mac password now your cocoapods will be replace with a stable version.
You can find out where the CocoaPods gem is installed with:
gem which cocoapods
if you have cloned the repo then type this command:
pod repo update
close your xcode and run this command
Pod install
This is a really quick & detailed solution
Open the Terminal and execute the following to get the latest stable version:
sudo gem install cocoapods
Add --pre to get the latest pre release:
sudo gem install cocoapods --pre
Incase any error occured
Try uninstall and install again:
sudo gem uninstall cocoapods
sudo gem install cocoapods
Run after updating CocoaPods
sudo gem clean cocoapods
After updating CocoaPods, also need to update Podfile.lock file in your project.
Go to your project directory
pod install
Very Smoot and Easy Solution
//MARK: -Latest stable version:
sudo gem install cocoapods --pre
//MARK: -If not work then
sudo gem install cocoapods --pre -n /usr/local/bin
//MARK: - if upper command not works you can use below mention command as well!
brew install cocoapods
brew upgrade cocoapods
brew link cocoapods
If this
sudo gem install cocoapods
gives you this error:
Could not find a valid gem 'cocoapods' (>= 0) in any repository
Try this:
sudo gem install cocoapods --source http://rubygems.org
I tried updating and it didn't work. Finally , I had to completely remove (manually )cocoapods, cocoapods-core , cocoapods-try.. and any other package used by cocoapods. Use this terminal command to list all the packages:
gem list --local | grep cocoapods
After that , I also deleted ./cocoapods folder from the user's root folder.
After trying all the steps above, with nothing working, I ran bundle update which seems to have done the trick for me.
Refer this link https://guides.cocoapods.org/using/getting-started.html
brew install cocoapods
brew upgrade cocoapods
brew link cocoapods
I have the problem in myproject when pod version and gem which cocoapods always return difference version.
All I had to do is remove Gemfile.lock in my project and bundle install again. It removed the locked cocoapods version and install a newer one.
Hope that helps some one here.
On my M1 Mac, I had a separate version of Homebrew installed for the Silicon/Arm64 side.
brew upgrade cocoapods was defaulting to a rosetta install of homebrew. I kept running it, and couldn't figure out why cocoapods was not updating. So I had to run it in a way that targets the M1 side of things instead of Rosetta.
I had previously aliased the Arm brew to mbrew. So I had to run mbrew upgrade cocoapods
If you updated sudo gem install cocoapods but it's still showing the old version you just need to type bundle update in your terminal to update the bundle and pod --version will show the newest version you installed
write on your terminal this:
sudo gem install cocoapods --pre
for update the gem of cocoapods to lastest version
First check cocoapods versionlike
pod --version
then update like
sudo gem install cocoapods --pre
after update you can also check cocoapods version.
I change the line "pod 'Alamofire', '~> 4.0'" to "pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire', :commit => '3cc5b4e'" after that in terminal: "pod install --repo-update" and it works.

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,
ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
rvm list rubies
=* ruby-2.5.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
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
You will probably solve this by installing the cocoapods gem into your current RVM-installed Ruby:
gem install cocoapods
Since you are using RVM, there is no need to ever use sudo for any commands to install or change anything about your Ruby. When installing gems with sudo gem install ..., you are installing it into your system's Ruby installation instead of your RVM Ruby. This can then cause issues in the interaction between the RVM environment and the system Ruby.
I run into same error.
But uninstall and sudo gem install -n /usr/local/bin cocoapods did NOT work for me.
So I tried rvm list rubies and found out there's a warning:
Warning! PATH is not properly set up, '/Users/xxx/.rvm/gems/ruby-2.1.3/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.1.3'.
I've no idea what's going on so I followed this issue: Warning! PATH is not properly set up, usually this is caused by shell initialization files
I did rvm reset & rvm version. The warning disappeared.
Then I run sudo gem install -n /usr/local/bin cocoapods
This fixed my problem. Post it here in case some one run into similar situation.
Try this
$sudo gem install cocoapods
If you already has cocoapods installed and you recently deleted or moved the current folder just try re-enter into the path again. Maybe terminal does not know where you are any more. This solved my problem.
Please install cocoapods into /usr/local/bin and not into /usr/bin with this command:
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
What did work for me I set 'command line tool path' in xcode preferences and was able to install missing pods

Fastlane Beta: Bundler::GemNotFound: Could not find CFPropertyList-3.0.0 in any of the sources

Running fastlane beta and getting this error:
Bundler::GemNotFound: Could not find CFPropertyList-3.0.0 in any of the sources
I tried installing the gem through the terminal, adding it to my gemfile, updating my fastlane version... no luck. Any ideas?
try
gem install CFPropertyList
update "You don't have write permissions for the ..."
sudo gem install CFPropertyList
I date with it error on cocoapods plugin:
I tried install CFPropetyList-3.0.0 manualy - not help, I did updates for all gems - no help.
Helped only: fastlane install_plugins command, it's updated cocoapods plugin for fastlane and now worked fine.
P.S. This error start to show after update to Mojave OS.
Update all gems:
sudo gem update --system
if this leads you to some error like:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted # rb_sysopen -
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem
Try running command:
sudo gem install -n /usr/local/bin cocoapods
This will remove this error Could not find CFPropertyList-3.0.0 in any of the sources
If you get error like this with bundle install while uploading you mobile app then go inside of the android/ios folder and run command:
bundle install
The problem was with my Ruby version :
Install rvm (if you don't have it) \curl -sSL https://get.rvm.io | bash
install latest ruby (3.0.0p0) rvm install ruby#latest and set it as default rvm use ruby-3.0.0 --default
A few times install cocoapods gem install cocoapods
pod install

Error installing CocoaPods

I am trying to install the latest CocoaPods (which is 0.36.1) but it shows me the following error.
$ gem install cocoapods
ERROR: Could not find a valid gem 'xcodeproj' (~> 0.23.1) in any repository
Sudo?
Btw, in the answered questions some are proposed using sudo get install cocoapods. You do need sudo indeed if you are using the system-wide ruby executable. I am using rbenv for my ruby management, it is installed locally for the user and does not need sudo.
Update
The gem install cocoapods command worked the following day. Mystery.
I think you could try an older version of the pods.
I tried: sudo gem install cocoapods -v 0.34.0 and this worked for me.
For your error you should do like this
i) $ sudo gem install xcodeproj
ii) $ sudo gem install cocoapods
for pod version you can verify pod --version
I think you need to update your gems repo.
try issuing "gem update" in a terminal. Can't remenber if you need sudo.
Try that, and then try installing xcodeproj and cocoapods again.
Regards
Steffen
If the automatic downloading of xcodeproj 0.23 fails, you can fetch the gem file manually:
gem fetch xcodeproj -v 0.23.0
This will put the .gem file in your current directory.
Then you can install the gem:
gem install xcodeproj -v 0.23.0
If the xcodeproj gem installs successfully, you can continue with your install of cocoapods as usual:
gem install cocoapods
Next time that occurs, run the command gem sources -u to update your source cache and try again.

when running pod install I get The `master` repo requires CocoaPods 0.32.1, try updating but still in 0.31

Iam trying to install cocoa pods in a xcode project, but when doing:
$ pod install
I get the following error:
Setting up CocoaPods master repo
[!] The `master` repo requires CocoaPods 0.32.1 -
Update CocoaPods, or checkout the appropriate tag in the repo.
/Library/Ruby/Gems/2.0.0/gems/claide-0.5.0/lib/claide/command.rb:281:in `rescue in run': undefined method `verbose?' for nil:NilClass (NoMethodError)
So I updated cocoapods
$ sudo gem update cocoapods
But it tells me there is nothing to update:
Password:
Updating installed gems
Nothing to update
run
pod --version
but I get:
0.31.0
What could it be? Why it is not updating to the latest version (.32.1)?
Xcode: 5.1
ruby: 2.0.0p353
OSX: 10.9.2
To update cocoapods just do
sudo gem install cocoapods
and then you should be at the correct version
This is what worked for me.
Uninstall CocoaPods (choose to uninstall all versions):
sudo gem uninstall cocoapods
Remove old master repo:
sudo rm -fr ~/.cocoapods/repos/master
Install CocoaPods without sudo:
gem install --user-install cocoapods
Setup CocoaPods and Master repo:
pod setup
NOTE: Step 3 is going to make sure you install pod under your user name instead of root which sudo does.
To update the version you must reinstall cocoapods:
sudo gem install cocoapods
The next step is You are going to Have to manually delete any copies of the Specs Local repository and re-clone the new version of the repository Specs. You can do that With the Following commands:
sudo rm -fr ~/.cocoapods/repos/master
pod setup
Finally:
pod install
that's what worked for me:
Uninstall CocoaPods (choose to uninstall all versions):
sudo gem uninstall cocoapods
Remove old master repo:
sudo rm -fr ~/.cocoapods/repos/master
Update gems as user installed:
sudo gem update --system --user-install
Add local gem path:
echo 'export PATH="$PATH:/Users/%username%/.gem/ruby/2.0.0/bin"' >> ~/.bash_login
Install CocoaPods without sudo:
gem install --user-install cocoapods
Setup CocoaPods and Master repo:
pod setup
make sure you are not running no-sudo commands from sudo terminal window/tab and relaunch or add new tap after exporting path
I had the same issue. I tried
sudo gem uninstall cocoapods
and then
sudo gem install cocoapods
but it wasn't working. It finally worked when I restarted Terminal after the uninstall. Then the install worked.

Resources