If you're encountering the "zsh: command not found: pod" error after successfully installing CocoaPods, it could be due to the pod
executable not being included in your system's PATH. To resolve this issue, you can try the following steps:
- Check if the pod executable is present in the
/usr/local/bin/
directory. Run the following command in terminal:
ls /usr/local/bin/pod
- If the pod executable is listed, Add the CocoaPods executable directory to your system's PATH. Open your shell's configuration file using a text editor. Run the following command in terminal:
open ~/.zshrc
- In the configuration file, add the following line:
export PATH="$PATH:/usr/local/bin"
- Reload the shell's configuration by running:
source ~/.zshrc
- Verify that CocoaPods is now accessible by running:
pod --version
It should display the version number of CocoaPods if the setup was successful.
But if the pod executable is not present in the /usr/local/bin/
directory after installing CocoaPods, it might be due to an issue during the installation process. To troubleshoot this, you can try the following steps:
- Ensure that Ruby and CocoaPods are installed correctly. Run the following commands to verify their installations:
ruby --version
gem --version
If both commands display the version numbers without any errors, proceed to the next step. Otherwise, you may need to reinstall Ruby and CocoaPods.
- Verify the installation location of the CocoaPods gem. Run the following command to check the gem installation paths:
gem environment
Look for the line that starts with "INSTALLATION DIRECTORY". Make a note of the path listed next to it.
- Check if the CocoaPods executable is present in the installation path. Run the following command, replacing <INSTALLATION_PATH> with the path obtained from the previous step:
ls <INSTALLATION_PATH>/bin/pod
- If the pod executable is listed, add the CocoaPods executable path to your system's PATH. Open your shell's configuration file using a text editor. For Zsh, you can use the following command:
open ~/.zshrc
- In the configuration file, add the following line, replacing <INSTALLATION_PATH> with the actual path from Step 2:
export PATH="<INSTALLATION_PATH>/bin:$PATH"
- Reload the shell's configuration by running:
source ~/.zshrc
- Verify that CocoaPods is now accessible by running:
pod --version
If the pod command displays the version number of CocoaPods, then the setup was successful.
If you're still experiencing issues after following these steps, it's recommended to uninstall and reinstall CocoaPods using a different method, such as using a package manager like Homebrew.
$PATH
? – Asteroidecho $PATH
– Asteroidls /usr/local/bin/pod
, if pod is not there, tryfind /Applications -name pod
– Asteroid