Cocoapods的安装以及遇到的问题

1

gem update --system

如果出现以下的报错,表示没有权限,去到第二步

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

2

sudo gem update --system

出现以下的提示,表示成功了

If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.

RubyGems system software updated

3 移除国外的镜像

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

4 添加国内的镜像

gem source -a https://gems.ruby-china.org/

4-1.错误

gem Error fetching https://gems.ruby-china.org/:
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

以上错误是因为ruby-china 更换了域名,换成https://gems.ruby-china.com即可

5 查看当前的镜像

gem sources -l

6 开始安装cocoapods

sudo gem install cocoapods

如果出现以下的情况,则是没有权限,跳至第七步

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

7

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

这个过程很漫长,有点耐心,去做点其他的事情....
等到出现以下的打印,就ok了

CocoaPods 1.4.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.4.0.beta.1

Setup completed

8 pod search出现的问题

[!] Unable to find a pod with name, author, summary, or description matching `afn`

删除cocoapods的索引

rm ~/Library/Caches/CocoaPods/search_index.json

然后重新pod search的时候,会出发cocoapods重新下载索引

pod search AFNetworking
Creating search index for spec repo 'master'.. 

遇到的问题

1、更新

xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ sudo gem install cocoapods -n/usr/local/bin
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
Password:
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ sudo gem install cocoapods -n/usr/local/bin
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ gem sources --add https://gems.ruby-china.com
https://gems.ruby-china.com added to sources
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
Password:
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ gem sources
*** CURRENT SOURCES ***

https://gems.ruby-china.org/
https://gems.ruby-china.com
xiaodeMacBook-Pro:~ xiao$ gem sources --remove https://gems.ruby-china.org/
https://gems.ruby-china.org/ removed from sources
xiaodeMacBook-Pro:~ xiao$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.7.7.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
xiaodeMacBook-Pro:~ xiao$ 

删除本地cocoapod然后重装

xiaodeMacBook-Pro:~ xiao$ which pod
/usr/local/bin/pod
xiaodeMacBook-Pro:~ xiao$ sudo rm -rf /usr/local/bin/pod
Password:
xiaodeMacBook-Pro:~ xiao$ gem list

*** LOCAL GEMS ***

activesupport (4.2.10)
bigdecimal (default: 1.2.8)
CFPropertyList (2.3.5, 2.2.8)
claide (1.0.2)
cocoapods (1.3.1)
cocoapods-core (1.3.1)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
did_you_mean (1.0.0)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.0.3)
i18n (0.9.0)
io-console (default: 0.4.5)
json (default: 1.8.3.1)
libxml-ruby (2.9.0)
minitest (5.8.5)
molinillo (0.5.7)
nanaimo (0.2.3)
nap (1.1.0)
net-telnet (0.1.1)
netrc (0.11.0)
nokogiri (1.5.6)
power_assert (0.2.6)
psych (default: 2.1.0.1)
rake (10.4.2)
rdoc (default: 4.2.1)
ruby-macho (1.1.0)
rubygems-update (2.7.7, 2.6.14)
sqlite3 (1.3.11)
test-unit (3.1.5)
thread_safe (0.3.6)
tzinfo (1.2.3)
xcodeproj (1.5.2)
xiaodeMacBook-Pro:~ xiao$ sudo gem uninstall cocoapods -v 1.3.1
Remove executables:
    pod, sandbox-pod

in addition to the gem? [Yn]  y
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
xiaodeMacBook-Pro:~ xiao$ sudo gem uninstall -n /usr/local/bin cocoapods -v 1.3.1
Remove executables:
    pod, sandbox-pod

in addition to the gem? [Yn]  y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.3.1
xiaodeMacBook-Pro:~ xiao$ pod search AFNetworking
-bash: pod: command not found
xiaodeMacBook-Pro:~ xiao$ sudo gem install cocoapods
Password:
Sorry, try again.
Password:
Fetching: cocoapods-core-1.5.3.gem (100%)
Successfully installed cocoapods-core-1.5.3
Fetching: cocoapods-deintegrate-1.0.2.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.2
Fetching: cocoapods-downloader-1.2.2.gem (100%)
Successfully installed cocoapods-downloader-1.2.2
Fetching: molinillo-0.6.6.gem (100%)
Successfully installed molinillo-0.6.6
Fetching: atomos-0.1.3.gem (100%)
Successfully installed atomos-0.1.3
Fetching: nanaimo-0.2.6.gem (100%)
Successfully installed nanaimo-0.2.6
Fetching: xcodeproj-1.7.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
xiaodeMacBook-Pro:~ xiao$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.7.0
Fetching: cocoapods-1.5.3.gem (100%)
Successfully installed cocoapods-1.5.3
Parsing documentation for xcodeproj-1.7.0
Installing ri documentation for xcodeproj-1.7.0
Parsing documentation for cocoapods-1.5.3
Installing ri documentation for cocoapods-1.5.3
Done installing documentation for xcodeproj, cocoapods after 4 seconds
2 gems installed
xiaodeMacBook-Pro:~ xiao$ pod --verson
[!] Unknown option: `--verson`
Did you mean: --version?

Usage:

    $ pod COMMAND

      CocoaPods, the Cocoa library package manager.

Commands:

    + cache         Manipulate the CocoaPods cache
    + deintegrate   Deintegrate CocoaPods from your project
    + env           Display pod environment
    + init          Generate a Podfile for the current directory
    + install       Install project dependencies according to versions from a
                    Podfile.lock
    + 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
xiaodeMacBook-Pro:~ xiao$ pod --version
1.5.3
xiaodeMacBook-Pro:~ xiao$ pod setup
Setting up CocoaPods master repo
  $ /usr/bin/git -C /Users/xiao/.cocoapods/repos/master fetch origin --progress
  remote: Enumerating objects: 124004, done.        
  remote: Counting objects: 100% (124004/124004), done.        
  remote: Compressing objects: 100% (205/205), done.        
  remote: Total 863826 (delta 123840), reused 123860 (delta 123784), pack-reused 739822        
  Receiving objects: 100% (863826/863826), 96.90 MiB | 6.01 MiB/s, done.
  Resolving deltas: 100% (587148/587148), completed with 10677 local objects.
  From https://github.com/CocoaPods/Specs
     d7d26ef24b1..4e96020248e  master     -> origin/master
  $ /usr/bin/git -C /Users/xiao/.cocoapods/repos/master rev-parse --abbrev-ref
  HEAD
  master
  $ /usr/bin/git -C /Users/xiao/.cocoapods/repos/master reset --hard
  origin/master
  Checking out files: 100% (88470/88470), done.
  HEAD is now at 4e96020248e [Add] AutoKeyboard 1.4.3
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 86259 and retry the command.

CocoaPods 1.6.0.beta.2 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.2

Setup completed
xiaodeMacBook-Pro:~ xiao$ pod search afn
Creating search index for spec repo 'master'.. Done!

[!] Skipping `MailCore2` because the podspec contains errors.

[!] Skipping `MiniPlengi` because the podspec contains errors.

[!] Skipping `OCast` because the podspec contains errors.

[!] Skipping `OCastReferenceDriver` because the podspec contains errors.

[!] Skipping `UriParser` because the podspec contains errors.
xiaodeMacBook-Pro:~ xiao$ 

2.pod install 运行后报错如下

[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/xiao/.cocoapods/repos` or via `pod repo add`.

解决:

pod repo add cocoapods https://github.com/CocoaPods/Specs.git
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容