最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

[已解决]Mac中尝试安装pod结果出错:-bash: pod: command not found

Mac crifan 1156浏览 0评论

折腾:

[已解决]Xcode编译项目出错:AFNetworking/AFNetworking.h file not found

期间,去安装pod出错:

licrifandeMacBook-Pro:git crifan$ ls -la
total 0
drwxr-xr-x   3 crifan  staff  102  4 29 18:20 .
drwxr-xr-x   4 crifan  staff  136  4 29 18:19 ..
drwxr-xr-x  14 crifan  staff  476  4 29 18:21 inquzhou
licrifandeMacBook-Pro:git crifan$ dc inquzhou/
licrifandeMacBook-Pro:git crifan$ pwd
/Users/crifan/dev/dev_root/daryun/Projects/inquzhou/git
licrifandeMacBook-Pro:git crifan$ ls -la
total 0
drwxr-xr-x   3 crifan  staff  102  4 29 18:20 .
drwxr-xr-x   4 crifan  staff  136  4 29 18:19 ..
drwxr-xr-x  14 crifan  staff  476  4 29 18:21 inquzhou
licrifandeMacBook-Pro:git crifan$ cd inquzhou/
licrifandeMacBook-Pro:inquzhou crifan$ ls -la
total 48
drwxr-xr-x  14 crifan  staff   476  4 29 18:21 .
drwxr-xr-x   3 crifan  staff   102  4 29 18:20 ..
-rw-r–r–@  1 crifan  staff  6148  4 29 18:26 .DS_Store
drwxr-xr-x  13 crifan  staff   442  4 29 18:26 .git
-rw-r–r–   1 crifan  staff   494  4 29 18:20 .gitignore
drwxr-xr-x  17 crifan  staff   578  4 29 18:20 INQuzhou
drwxr-xr-x  10 crifan  staff   340  4 29 18:24 INQuzhou.xcodeproj
drwxr-xr-x   3 crifan  staff   102  4 29 18:20 INQuzhou.xcworkspace
drwxr-xr-x   4 crifan  staff   136  4 29 18:20 INQuzhouTests
drwxr-xr-x   4 crifan  staff   136  4 29 18:20 INQuzhouUITests
-rw-r–r–   1 crifan  staff   527  4 29 18:20 Podfile
-rw-r–r–   1 crifan  staff  1733  4 29 18:20 Podfile.lock
drwxr-xr-x  14 crifan  staff   476  4 29 18:20 Pods
-rw-r–r–   1 crifan  staff    11  4 29 18:20 README.md
licrifandeMacBook-Pro:inquzhou crifan$ pod install –verbose –no-repo-update
-bash: pod: command not found
licrifandeMacBook-Pro:inquzhou crifan$

mac pod: command not found

cocoapods – pod install -bash: pod: command not found – Stack Overflow

cocoapods – Can not perform `pod install` under el capitan (15A279b) – Stack Overflow

"pod: command not found" after installing on OS X El Capitan Beta 2 · Issue #3736 · CocoaPods/CocoaPods

macbook – Trying to install CocoaPods using terminal getting command not found – Ask Different

CocoaPods Guides – Troubleshooting

去安装,结果卡死不动了:

licrifandeMacBook-Pro:inquzhou crifan$ sudo gem install cocoapods
Password:
^CERROR:  Interrupted

CocoaPods.org

后来看到错误了:

[已解决]gem install cocoapods出错:ERROR Could not find a valid gem cocoapods >= 0

终于安装完毕了,去看看版本:

licrifandeMacBook-Pro:inquzhou crifan$ pod –version
0.39.0

然后去:

pod setup

但是太慢,所以取消了:

licrifandeMacBook-Pro:inquzhou crifan$ pod setup
Setting up CocoaPods master repo
^C[!] Cancelled

然后参考:

如何使用CocoaPods – snowell – SegmentFault

去换成oschina的:

http://git.oschina.net/akuandev/Specs.git

结果不小心,用了gitcafe的:

licrifandeMacBook-Pro:inquzhou crifan$ pod repo remove master
[!] repo master does not exist
Usage:
    $ pod repo remove NAME
      Deletes the remote named `NAME` from the local spec-repos directory at
      `~/.cocoapods/repos/.`
Options:
        Show nothing
      Show more debugging information
      Show output without ANSI codes
          Show help banner of specified command
licrifandeMacBook-Pro:inquzhou crifan$ pod repo add master https://gitcafe.com/akuandev/Specs.git
Cloning spec repo `master` from `https://gitcafe.com/akuandev/Specs.git`
CocoaPods 1.0.0.rc.2 is available.
To update use: `gem install cocoapods –pre`
[!] This is a test version we’d love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

注:

其实不太应该用:

https://gitcafe.com/akuandev/Specs.git

因为gitcafe已经停用-》合并到coding码市了。。。

最好用:

http://git.oschina.net/akuandev/Specs.git

licrifandeMacBook-Pro:inquzhou crifan$ pod repo update
Updating spec repo `master`
Updating 4a34dc8..65e4999
Fast-forward
 Specs/Cloudipsp/0.1.3/Cloudipsp.podspec.json       | 25 +++++++
 …/0.1.4/PR2StudioSwift.podspec.json              | 27 +++++++
 Specs/SuperAwesome/3.8.8/SuperAwesome.podspec.json | 83 ++++++++++++++++++++++
 …/2.1.0/SwiftValidators.podspec.json             | 20 ++++++
 Specs/eeGeo/1.0.551/eeGeo.podspec.json             | 56 +++++++++++++++
 5 files changed, 211 insertions(+)
 create mode 100644 Specs/Cloudipsp/0.1.3/Cloudipsp.podspec.json
 create mode 100644 Specs/PR2StudioSwift/0.1.4/PR2StudioSwift.podspec.json
 create mode 100644 Specs/SuperAwesome/3.8.8/SuperAwesome.podspec.json
 create mode 100644 Specs/SwiftValidators/2.1.0/SwiftValidators.podspec.json
 create mode 100644 Specs/eeGeo/1.0.551/eeGeo.podspec.json
   4a34dc8..65e4999  master     -> origin/master
CocoaPods 1.0.0.rc.2 is available.
To update use: `gem install cocoapods –pre`
[!] This is a test version we’d love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

然后再去设置:

licrifandeMacBook-Pro:inquzhou crifan$ pod setup
Setting up CocoaPods master repo
Updating 65e4999..e0adf5c
Fast-forward
 Specs/GetSocial/5.0.2/GetSocial.podspec.json | 65 ++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Specs/GetSocial/5.0.2/GetSocial.podspec.json
   65e4999..e0adf5c  master     -> origin/master
 * [new branch]      fix/PODS_ROOT -> origin/fix/PODS_ROOT
 * [new branch]      revert-13358-crashlytics-3.1.0-podspec-fix -> origin/revert-13358-crashlytics-3.1.0-podspec-fix
 * [new branch]      revert-13365-revert-13358-crashlytics-3.1.0-podspec-fix -> origin/revert-13365-revert-13358-crashlytics-3.1.0-podspec-fix
CocoaPods 1.0.0.rc.2 is available.
To update use: `gem install cocoapods –pre`
[!] This is a test version we’d love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Setup completed

期间去看进度:

另外打开terminal:

licrifandeMacBook-Pro:~ crifan$ cd ~/.cocoapods/
licrifandeMacBook-Pro:.cocoapods crifan$ du -sh *
578M repos

[记录]研究和学习已有的支持cocoapods的项目中和cocoapods相关的文件

-》

最终,双击对应的

INQuzhou.xcworkspace

即可打开项目了:

也就可以正常编译和运行项目了:

[总结]

安装cocoapods过程用的命令:

用:

gem sources -l

查看当前的gem的源

去删除https的源:

gem sources –remove https://rubygems.org/

去添加,速度慢的国外的最官方的http的源:

gem sources –add http://rubygems.org/

或者是:

添加国内的,速度快的,淘宝的(之前是http,后来已改为)https的源:

gem sources –add https://ruby.taobao.org/

然后去update确保源的内容是最新的:

sudo gem update –system

由于Mac中,即使是sudo的权限,都不允许直接操作写入/usr/bin

-》而直接用:

sudo gem install cocoapods

会默认安装cocoapods到

/usr/bin/

-》所以会出错:

ERROR:  While executing gem … (Errno::EPERM)

    Operation not permitted – /usr/bin/xcodeproj

为了正常能安装cocoapods,则把安装路径设置为:

/usr/local/bin

即,用:

sudo gem install -n /usr/local/bin cocoapods

安装,就可以正常安装cocoapods了。

安装完毕后,会看到:

14 gems installed

之类的字样。

然后可以用:

pod –version

去查看当前版本。

对于当前的repo的master,默认刚安装完毕,好像没有master,所以不需要去使用,别人说的:

pod repo remove master

再去添加master的源,仓库:

国外的很慢,果然有好心人弄了两个:

gitcafe的和oschina的

-》

由于gitcafe已经停用(已被合并到coding码市了。。。)

所以最好不要用:

https://gitcafe.com/akuandev/Specs.git

而是用oschina的:

http://git.oschina.net/akuandev/Specs.git

即:

再去更新一下:

pod repo update

再去设置:

pod setup

之后即可去使用cocoapods去管理iOS的第三方的库了。

此处贴上一些还不错的教程:

如何使用CocoaPods – snowell – SegmentFault

CocoaPods的安装使用和常见问题 – 简书

“1.从此以后需要使用Cocoapods生成的 .xcworkspace文件来打开工程,而不是使用以前的.xcodeproj文件

2.每次更改了Podfile文件,都需要重新执行一次pod update命令

ps:当执行pod install之后,除了Podfile,还会生成一个名为Podfile.lock的文件,它会锁定当前各依赖库的版本,之后即使多次执行pod install也不会更改版本,只有执行pod update才会改变Podfile.lock.在多人协作的时候,这样可以防止第三方库升级时候造成大家各自的第三方库版本不一致。所以在提交版本的时候不能把它落下,也不要添加到.gitignore中.”

转载请注明:在路上 » [已解决]Mac中尝试安装pod结果出错:-bash: pod: command not found

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
63 queries in 0.115 seconds, using 18.92MB memory