xcode “pod init”给出错误“-bash:pod:找不到命令”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41064579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"pod init" giving error "-bash: pod: command not found"
提问by Ethan Humphries
I am trying to create a Podfile for my Xcode project for Firebase compatibility, but when I try to create it within the same file that my Xcode project is stored in, using my terminal and typing "pod init", it throws the error "-bash: pod: command not found".
我正在尝试为我的 Xcode 项目创建一个 Podfile 以实现 Firebase 兼容性,但是当我尝试在存储我的 Xcode 项目的同一个文件中创建它时,使用我的终端并输入“pod init”,它会抛出错误“- bash: pod: 命令未找到”。
I am up to date on OSX as far as I'm aware, using Sierra 10.12.1, but I am unfamiliar with the use of Podfiles, so any help here would be great, thanks.
据我所知,我在 OSX 上是最新的,使用 Sierra 10.12.1,但我不熟悉 Podfiles 的使用,所以这里的任何帮助都会很棒,谢谢。
回答by Caleb Kleveter
Looks like you didn't install CocoaPods.
看起来您没有安装 CocoaPods。
To do that you install it through ruby gems, like this:
为此,您可以通过 ruby gems 安装它,如下所示:
sudo gem install cocoapods
If you don't have admin privileges, try:
如果您没有管理员权限,请尝试:
gem install cocoapods --user-install
回答by Diptendu Das
if the 1st command doesn't work, try the 2nd command
如果第一个命令不起作用,请尝试第二个命令
sudo gem install cocoapods
sudo gem install -n /usr/local/bin cocoapods
In my case, the 2nd command worked
就我而言,第二个命令有效
回答by asaf am
回答by Samarey
For OS Catalina (as of December 2019)
对于 OS Catalina(截至 2019 年 12 月)
gem install -n /usr/local/bin cocoapods
回答by Haider Malik
I ran into this problem yesterday, I reckon others in my situation will be too. So I am running a mac OS siera on a virtual machine on my windows so I can use xcode. Firstly you will need to update your version of ruby, it has been answered here: https://stackoverflow.com/a/38194139/7451779.
我昨天遇到了这个问题,我想我的情况下的其他人也会遇到这个问题。所以我在 Windows 上的虚拟机上运行 mac OS siera 以便我可以使用 xcode。首先,您需要更新您的 ruby 版本,已在此处回答:https: //stackoverflow.com/a/38194139/7451779。
Once updated this just run: $ sudo gem install cocoapods
更新后,只需运行:$ sudo gem install cocoapods
After all this $ pod init should work
毕竟这 $ pod init 应该可以工作