Unknown command 'pod' in directory / - ios

Why I can't use cocoapods command pod in directory /
/ $ pod
fish: Unknown command 'pod'
/ $
If use command in home directory, it work well.
~ $ pod
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.

Find the reason, my cocoapods install in chruby ruby 2.4, and .ruby-version file in home directory.
So, the root directory not have .ruby-version file, just use system base ruby, that not install cocoapods. So Unknown command error occur.
At last, I copy my ~/.ruby-version to /.ruby-version, it's work!

Related

Pod init not working after updating terminal(Some popup came to change to ZSH)

I don't know what went wrong, everything was working fine until terminal showed me Popup and my default terminal which used to open with nileshjha#Nileshs-MacBook-Air $ changed to nileshjha#Nileshs-MacBook-Air ~ % .. And after that pod stopped working. I tried all ways to change it back to previous . But didn't succeed.
Now when i am doing pod init , I am getting this error.
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
Can you please help me out of this.
I have MacOS Catalina, and am trying to update cocoa pods.
I received an error when I tried running pod update
Here is the error message:
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
Next, I ran sudo gem install cocoapods
That was all that was needed. pod update worked fine after that
The same initial issue occurred when attempting to setup GoogleMaps in a Flutter app after running pod install on the iOS directory.
Running pod install the following error appeared:
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
Next, after running sudo gem install cocoapods, that resulted in another error:
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
kevin recommends installing Xcode Developer Tools running:
xcode-select --install
and while highlighting the need to install the tools, the system again produced the same error as before when running the pod install command.
Refresing the tools by removing and reinstalling them became the next target. The tools are removed with the following command:
rm -rf /Library/Developer/CommandLineTools
And again installing the xcode developer tools using:
xcode-select --install
Then, sudo gem install cocoapods and pod install ran successfully.

Where is the pod file in xcode located? [duplicate]

I referred to many links and tried, but I had no success. I read CocoaPods documents and many times tried to install, but I always failed because of the starting steps. I found one error whereby I can't install gems first. What are the steps one by one? Such as steps or a demo of how to install.
This is one link which I tried.
The screenshot refers to this console error I was given:
POD Install
Open terminal and type:
sudo gem install cocoapods
The Gem will get installed in Ruby inside the System library. Or try on Mac OS X v10.11 (El Capitan), type:
sudo gem install -n /usr/local/bin cocoapods
If there is an error "activesupport requires Ruby version >= 2.xx", then install latest activesupport first by typing in the terminal.
sudo gem install activesupport -v 4.2.6
After installation, there will be a lot of messages. Read them and if no error found, it means the CocoaPods installation is done. Next, you need to setup the CocoaPods master repository. Type in the terminal:
pod setup
And wait it will download the master repository. The size is very big (370.0 MB in December 2016). So it can be a while. You can track of the download by opening Activity and go to the Network tab and search for "git-remote-https". Alternatively, you can try adding "--verbose" to the command like so:
pod setup --verbose
Once done, it will output "Setup Complete", and you can create your Xcode project and save it.
Then in the terminal, cd to your Xcode project root directory (where your .xcodeproj file resides) and type:
pod init
Then open your project's podfile by typing in terminal:
open -a Xcode Podfile
Your Podfile will get open in text mode. Initially there will be some default commands in there. Here is where you add your project's dependencies. For example, in the podfile, type
pod 'AFNetworking', '0.9.1'
(This line is an example of adding the AFNetworking library to your project.)
Other tips:
Uncomment platform :ios, '9.0'
Uncomment use_frameworks! if you're using Swift
When you are done editing the podfile, save it and close Xcode.
Then install pods into your project by typing in terminal:
pod install
or (For m1 chip)
arch -x86_64 pod install
Depending how many libraries you added to your podfile for your project, the time to complete this varies. Once completed, there will be a message that says
"Pod installation complete! There are X dependencies from the Podfile
and X total pods installed."
Now close your Xcode project. Then locate and open the .xcworkspace Xcode project file and start coding. (You should no longer open the xcodeproj file.)
First open your terminal
Then update your gem file with command
sudo gem install -n /usr/local/bin cocoapods
Then give your project path
cd /your project path
Touch the podifle
touch podfile
Open your podfile
open -e podfile
It will open a podfile like a text edit. Then set your target. For example if you want to set up Google maps then your podfile should be like
use_frameworks!
target 'yourProjectName' do
pod 'GoogleMaps'
end
Then install the pod
pod install
On macOS v10.14 (Mojave) with Xcode 10.3, I got scary warnings from the gem route with or without -n /usr/local/bin:
xcodeproj's executable "xcodeproj" conflicts with /usr/local/bin/xcodeproj
Overwrite the executable? [yN]
What works for me is still Homebrew. Just:
brew install cocoapods
This works for Mac OS X v10.11.x (El Capitan)
sudo gem install -n /usr/local/bin cocoapods
After this, you can set up the pod using pod setup cmd and then move to your project directory and install pod.
Simple steps to install a pod file:
Open the terminal
Command on the terminal: sudo gem install cocoapods
Set your project path in the terminal.
Command: pod init
Go to the pod file of your project and add the pod which you want to install
Added in the pod file: pod 'AFNetworking', '~> 3.0
Command: Pod install
Close the Xcode project
open your project from the terminal
Command: open PodDemos.xcworkspace
Year 2020, installing CocoaPods v1.9.1 in macOS v10.15 (Catalina)
First set up your Xcode version in your Mac using the terminal.
sudo xcode-select -switch /Applications/Xcode.app
Next, install CocoaPods using the terminal.
sudo gem install cocoapods
For more information, visit the official website, https://cocoapods.org/.
These are the complete steps that I usually follow. I am posting these steps as short as possible and assuming that you know about Mac and Xcode projects. First of all, open the terminal and use the following commands, and press enter after each command.
Type in the following command if you don't already have CocoaPods installed:
sudo gem install cocoapods
Now please move to your Xcode Project directory by using this following command, and replace /Your Xcode Project Directory Path with the actual path to the directory:
cd /Your Xcode Project Directory Path
Below are instructions for how to use CocoaPods. Please wait for some time after each and every command entered to the terminal to execute successfully.
Searching for pods in terminal:
pod search networking (replace networking with which you want to search)
Creating the pod file:
pod init
Opening the pod file:
open -a Xcode Podfile
Adding the pods: (After adding your pods you must save the podfile first and then head back to the terminal again.)
target 'WebServiceUsingMantleAFNetworking' do
# platform :ios, '8.0' //Choose your version of iOS
pod 'AFNetworking', '~> 2.6.0’
end
OR
platform :ios, '8.0'
pod 'AFNetworking'
pod 'Mantle'
pod 'LBBlurredImage'
pod 'TSMessages'
pod 'ReactiveCocoa'
Installing the pods:
pod install
Check for updates of pods on existing project:
pod outdated
Update the existing pods:
pod update
Uninstall the Cocoapods from system:
sudo gem uninstall cocoapods
There is a complete tutorial for removing pods from your Xcode project on Stack Overflow. You can check on this following link for more info.
How to remove CocoaPods from a project?
Open Terminal
Type in sudo gem install cocoapods if you don't have CocoaPods
Enter cd /project path, but replace project path with actual project path
touch podfile
Use one of the following commands to open the podfile:
open -e podfile to open in TextEdit or
open -a pod file to open in Xcode
Set your target and add pod file of GoogleMaps like as:
target 'PROJECT NAME HERE' do
pod 'GoogleMaps'
end
Use pod install to install dependencies
Here are all steps with an image. Please follow it properly and I am sure you will not get any error.
From How to install CocoaPods and setup with your Xcode project.
First of all, check you have to install command line or not.
You can check this by opening Xcode, navigating the menu to
Xcode → Preferences → Downloads → Components. Find Command Line Tools and select install/update.
If you haven't found command line tool then you need to write this command in the terminal:
xcode-select --install
And click on install.
If you have installed the command-line tool, you need to select your Xcode directory (sometimes these type of problems created due to different versions of Xcode available)
Follow this procedure.
Open terminal and run this command:
sudo gem install cocoapods
Enter the admin password. This could take a while. After a few minutes, it
will show a green message if CocoaPods installed successfully in your
Mac machine.
If you are getting any error with Xcode 6 like developer path is
missing. First run this command in terminal:
sudo xcode-select -switch /Applications/Xcode6.app (or your XCodeName.app)
Now you can set up Pod with your Xcode project.
And now you have to install pod. Follow this procedure.
Open Terminal
Change directory to your Xcode project root directory (where your
ProjectName.xcodeproj file is placed).
pod setup: (Setting up the CocoaPods master repository)
If successful, it shows: Setup completed (read-only access). So,
you set up everything. Now let’s do something which is more visible…Yes! Let’s install libraries in your Xcode project.
Now you have to set up and update the library related to pod in your project.
Steps to add-remove-update libraries in pod:
Open Terminal
Change directory to your Xcode project root directory. If your
terminal is already running then there isn't any need to do this, as you are
already at the same path.
touch pod file
open -e podfile (This should open a blank text file)
Add your library names in that text file. You can add new names
(library name), remove any name or change the version, e.g.:
pod ’Facebook-iOS-SDK’
pod ’EGOTableViewPullRefresh’
pod ’JSONKit’
pod ‘MBProgressHUD
NOTE: Use the (control + ”) button to add single quote at both end of library name. It should be shown as straight vertical line. Without
control button it shall be added as curly single quote which will give
error while installation of file.
Save and close this text file. Now libraries are set up and you have
to install/update it
Go to your terminal again and run this command: pod install
(to install/update these libraries in pod).
You should see output similar to the following:
Updating spec repo `master’ \
Installing Facebook-iOS-SDK \
Generating support files
Setup completed.
Note:
If you have followed this whole procedure correctly and step by step, then you can directly fire the pod update command after selecting Xcode and then select your project path. And write your command pod update.
You can also check a command line tool here:
CocoaPods Installation on macOS v10.13 (High Sierra):
Install Homebrew - https://brew.sh/
Execute the following commands in the terminal:
sudo gem update --system
sudo gem install activesupport -v 4.2.6
sudo gem install -n /usr/local/bin cocoapods
pod setup
pod setup --verbose
For macOS v10.15 (Catalina):
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
The latest CocoaPods 1.10.0 seem not to be working.
I found the answer in Trouble with installing CocoaPods.
1- Install the Cocoapods in your machine
$ sudo gem install cocoapods
$ pod setup --verbose
2- Check whether Cocoapods is installed on your machine or not?
$ pod --version
3- Go to your project directory where .xcodeproj is present
$ pod init
After using pod init one additional file is added in your folder of name Podfile.
4- By double click open the podfile and pods between target and end
5- Install Pod using command
pod install
When you run the pod install command it installs all pods which you write in the pod file. And after you install the required commands open the project directory you get 2 new files.
First is Podfile.lock -> Every time the pod install command is run — and downloads and install new pods — it writes the version it has installed, for each pod, in the Podfile.lock file.
Second is .xcworkspace -> Xcode workspace files can be used as a wrapper or container for an Xcode .XCODEPROJ project.
Now use your library by using .xcworkspace which have a white background colour.
Pod installation giving an error on Mac OS X v10.11.2 (El Capitan):
ERROR: Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
After getting this error, I tried this command and installed again. It worked for me.
sudo gem install activesupport -v 4.2.6
Now try the same pod installation command
sudo gem install -n /usr/local/bin cocoapods
For me, the easiest way was to install via a Ruby gem:
sudo gem install cocoapods -v
Please note -v for verbose. It takes a while to install CocoaPods and often you get confused if it's really happening.
You can install CocoaPods via Homebrew in macOS.
First, open your terminal, and run this code (for installing Homebrew if you have not): Go here for the latest command.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install CocoaPods easily via this command:
brew install cocoapods
sudo gem install -n /usr/local/bin cocoapods
This worked for me. -n helps you fix the permission error.
Pod File Install Steps
sudo gem install -n /usr/local/bin cocoapods
Pod setup
cd ~/Path/To/Folder/Containing/ShowTracker
touch podfile
open -a Xcode Podfile // To open it in Xcode
OPEN -e podfile // To open it in text editor
pod install // To install a new pod
pod update // To update all pods
Works in macOS Big Sur
1 install LATEST version of brew (https://treehouse.github.io/installation-guides/mac/homebrew)
2 then use "brew uninstall cocoapods"
3 install the latest version of cocoapods using "brew install cocoapods" (You must verify installed version with github version https://github.com/CocoaPods/CocoaPods/releases/tag/1.11.2, they must match)
4 overwrite link to cocoapods with "brew link --overwrite cocoapods"
5 check the version of cocoapods "pod --version"
6 done, You have the latest version of cocoapods installed
Normally we use
sudo gem install cocoapods
Solution, fix for CocoaPods error on Mac OS X v10.11 (El Capitan):
sudo gem install -n /usr/local/bin cocoapods
pod setup
cd /project path
pod init
In Podfile we need to set the target
# Podfile
platform :ios, '9.0'
use_frameworks!
# My other pods
target “Projectname” do
pod 'MBProgressHUD', '~> 0.8'
pod 'Reachability', '~> 3.1.1'
pod 'AFNetworking', '~> 2.2'
pod 'TPKeyboardAvoiding', '~> 1.2'
end
target 'ProjectnameTests' do
testing_pods
end
target 'ProjectnameUITests' do
testing_pods
end
In the console - terminal
pod install
If you behind a proxy then pass the proxy as an argument:
sudo gem install --http-proxy http://user:password#www-proxy.example.com:80 cocoapods
Thanks to SwiftBoy's 10-step solution I successfully used CocoaPods to setup the latest version of AudioKit.
1. Using Xcode create MyAudioApp Swift project saving it to my Developer directory e.g.
/Users/me/Developer/MyAudioApp
2. Using Cocoapods install AudioKit within MyAudioApp project (i.e. install AudioKit sdk)
3. Open Terminal, type command below and press Enter
sudo gem install -n /usr/local/bin cocoapods
4. Provide system password and press Enter
5. In Terminal, type command below and press Enter
cd /Users/me/Developer/MyAudioApp
6. Create project pod file - in Terminal type command below and press Enter
touch Podfile
7. Open project pod file - in Terminal type command below and press Enter (opens in TextEdit)
open Podfile
8. Edit code below into open pod file (and save file before quitting TextEdit)
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.2'
use_frameworks!
target 'MyAudioApp' do
pod 'AudioKit', '~> 4.7'
end
9. To install AudioKit in MyAudioApp workspace type Terminal command below and press Enter
Pod install
and wait for install to finish
10. In Finder, go to project folder /Users/me/Developer/MyAudioApp
and click .xcworkspace file below (opens in Xcode!)
/Users/me/Developer/MyAudioApp/MyAudioApp.xcworkspace
11. In MyAudioApp edit ViewController.swift and insert the following
import AudioKit
CocoaPods installation step:
Open your Terminal:
sudo gem update --system
sudo gem install activesupport -v 4.2.6
sudo gem install cocoapods
pod setup
pod setup --verbose
Then go to your project directory with Terminal:
cd Your Project Path
Then enter the below command in Terminal:
pod init
open -a Xcode Podfile
(Edit POD file with pod ‘libname’)
pod install
For CocoaPods in the terminal, follow this:
sudo gem update
sudo gem install cocoapods
pod setup
cd (project direct drag link)
pod init
open -aXcode podfile # (If it’s already open, add your pod file name. Example: alamofire4.3)
pod install
pod update
Open Terminal
Enter $ sudo gem install cocoapods command in terminal
Create new Xcode project
Navigate to directory containing Xcode project. Use cd “../directory-location/..” or cd [drag-and-drop project folder]
Pod install
If this prompts error Unable to add a source with url.. then install command line tool for Xcode. Again, rerun Pod install command.
This will install all dependencies as well.
Now, open your project in Workspace i.e. Project-Name.xcworkspace rather than Project-Name.xcodeproj
If you want to install CocoaPods for the first time for your project.
Example: Here we will install the "Alamofire" SDK using CocoaPods step by step.
Step 1. Open Terminal, hit command, and then press the Enter key
sudo gem install cocoapods
Step 2. If it asks, you should provide system password and then press the Enter key
Step 3. With command “cd” and give the path of your project and then press the Enter key
Note: type the "cd" command then space and drag the project folder to the terminal. It will take the project path as shown below (here my project name is: Simple Alamofire)
cd /Users/ramdhanchoudhary/Documents/Swift\ Workspace/Simple\
Alamofire
Step 4. Create a pod file in your project by terminal by command “touch Podfile” and press “Enter”
touch Podfile
Step 5. Then, open “Podfile” by terminal command “open Podfile” and press “Enter”
open Podfile
Step 6. Now type following code in opened pod file then save and close file
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Alamofire', '~> 4.0'
end
Step 7. Back in Terminal type command “Pod install” and then press Enter Key.
Pod install
Step 8. Wait for the install to get complete 100% its around 650+ MB
Step 9. That's it goto project folder and open below file
<your project name>.xcworkspace
Step 10. Import Alamofire class and use!!
import Alamofire
On mac M1
I had two cocoapods installed, one was using brew and one with gem. With 2 different versions.
After reading many of your posts, and try many things I encountered various troubles.
Finally this one help me : thanks to Evan
With his post : https://stackoverflow.com/a/70600723/2355088
The final working sequence for me probably was :
sudo gem uninstall cocoapods
brew uninstall cocoapods
brew install cocoapods
brew reinstall ruby
=> RESTART ALL TERMS <= magical step, thank you Evan
cd myProj
pod install
Check this
gem install -p http://proxy_ip:proxy_port compass
You might need to add your user name and password to it:
gem install -p http://[username]:[password]#proxy_ip:proxy_port compass
And check this link it may help you.
For Mac OS X v10.11 (El Capitan)
rvm install ruby-2.2.2.
rvm use ruby-2.2.2.
sudo gem install -n /usr/local/bin cocoapods
I was facing the same problem in mac after updating to macOS 12.1
Also you might get error attached with Ruby framework installed on your mac machine.
You just need to remove cocoa pods completely from mac and re-install cocoapods
And then reinstall your project pods
This will solve your problem
for Apple Silicon Mac
$ sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc

XCode doesn't recognize `pod keys`

Here's my setup
Env:
Mac 10.11.6
Gem 2.4.8
Gemfile:
source 'https://rubygems.org'
gem 'cocoapods', '~> 1.1.1'
gem 'cocoapods-keys', '~> 1.7.0'
gem 'fastlane'
Installed Cocoapods-keys using:
gem install cocoapods-keys
Added Fabric Run Script:
"${PODS_ROOT}/Fabric/iOS/Fabric.framework/run" `pod keys get FabricAPIKey` `pod keys get FabricAPISecret`
Errors:
[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
[0m
~/Development/Projects/ABC/raven/Pods/Fabric/iOS/Fabric.framework/run: eval: line 18: syntax error near unexpected token `('
~/Development/Projects/ABC/raven/Pods/Fabric/iOS/Fabric.framework/run: eval: line 18: `"~/Development/Projects/ABC/raven/Pods/Fabric/iOS/Fabric.framework/uploadDSYM" [!] Unknown command: `keys` Did you mean: repo Usage: $ pod COMMAND CocoaPods, the Cocoa library package manager. Commands: + cache Manipulate the CocoaPods cache + init Generate a Podfile for the current directory. + install Install project dependencies to Podfile.lock versions + ipc Inter-process communication + lib Develop pods + list List pods + outdated Show outdated project dependencies + plugins Show available CocoaPods plugins + repo Manage spec-repositories + search Search for pods. + setup Setup the CocoaPods environment + spec Manage pod specs + trunk Interact with the CocoaPods API (e.g. publishing new specs) + try Try a Pod! + update Update outdated project dependencies and create new Podfile.lock Options: --silent Show nothing --version Show the version of the tool --verbose Show more debugging information --no-ansi Show output without ANSI codes --help Show help banner of specified command [!] Unknown command: `keys` Did you mean: repo Usage: $ pod COMMAND CocoaPods, the Cocoa library package manager. Commands: + cache Manipulate the CocoaPods cache + init Generate a Podfile for the current directory. + install Install project dependencies to Podfile.lock versions + ipc Inter-process communication + lib Develop pods + list List pods + outdated Show outdated project dependencies + plugins Show available CocoaPods plugins + repo Manage spec-repositories + search Search for pods. + setup Setup the CocoaPods environment + spec Manage pod specs + trunk Interact with the CocoaPods API (e.g. publishing new specs) + try Try a Pod! + update Update outdated project dependencies and create new Podfile.lock Options: --silent Show nothing --version Show the version of the tool --verbose Show more debugging information --no-ansi Show output without ANSI codes --help Show help banner of specified command validate run-script'
Command /bin/sh failed with exit code 1
Fixes that I've tried that didn't work:
added export LANG=en_US.UTF-8 to ~/.profile, ~/.bash_profile
export LANG=en_US.UTF-8 using this
fix permission using this
deleted /Pods, Pod.lock and ran bundle install and bundle exec pod install
Things that works:
On Terminal, run pod keys
So apparently pod keys runs well on my mac, but XCode doesn't recognise it, any thoughts are greatly appreciated!
Have you tried bundle exec pod install inside the script?

How to locate "Podfile" in iOS project? for add firebase to use facebook login

I can't find this file and when I open new one it cannot install it.
I tried to open "pod init".
Are there other ways to do it?
In Mac
First navigate to the directory that you want pods to exist in.
Run:
$ sudo gem install cocoapods
$ pod init
then you should have a new Podfile.
To open it using vim Run:
$ vim Podfile
Once you've added your pods, Run:
$ pod install
to install them

cocoapods not installing

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

Resources