關(guān)于CocoaPods安裝的問題(如果你遇到不同情況的問題并解決,一起更新)

第一步:sudo gem update --system

如果失敗則用這條語句

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

如果是最新版的會出現(xiàn)Latest version currently installed. Aborting.

如果不是會出現(xiàn)

Updating rubygems-update

Fetching: rubygems-update-2.5.0.gem (100%)

Successfully installed rubygems-update-2.5.0

Parsing documentation for rubygems-update-2.5.0

Installing ri documentation for rubygems-update-2.5.0

Installing darkfish documentation for rubygems-update-2.5.0

Installing RubyGems 2.5.0

RubyGems 2.5.0 installed

Parsing documentation for rubygems-2.5.0

Installing ri documentation for rubygems-2.5.0

------------------------------------------------------------------------------

RubyGems installed the following executables:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem

Ruby Interactive (ri) documentation was installed. ri is kind of like man

pages for ruby libraries. You may access it like this:

ri Classname

ri Classname.class_method

ri Classname#instance_method

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

第二步:移除舊的ruby

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

成功后會出現(xiàn)source https://rubygems.org/ not present in cache

第三步:安裝新的

gem sources -a https://ruby.taobao.org/

成功后會出現(xiàn)https://ruby.taobao.org/ added to sources

第四步:查看gem sources -l

成功后會出現(xiàn)

*** CURRENT SOURCES ***

https://ruby.taobao.org/

第五步:安裝

sudo gem install cocoapods

失敗的出現(xiàn)結(jié)果

Fetching: i18n-0.7.0.gem (100%)

Successfully installed i18n-0.7.0

Fetching: thread_safe-0.3.5.gem (100%)

Successfully installed thread_safe-0.3.5

Fetching: tzinfo-1.2.2.gem (100%)

Successfully installed tzinfo-1.2.2

Fetching: minitest-5.8.3.gem (100%)

Successfully installed minitest-5.8.3

Fetching: activesupport-4.2.5.gem (100%)

Successfully installed activesupport-4.2.5

Fetching: nap-1.0.0.gem (100%)

Successfully installed nap-1.0.0

Fetching: fuzzy_match-2.0.4.gem (100%)

ERROR:? While executing gem ... (Errno::EPERM)

Operation not permitted - /usr/bin/fuzzy_match

lihuandeMac-mini:~ lihuan$ pod setup

-bash: pod: command not found

lihuandeMac-mini:~ lihuan$ sudo gem install cocoapods

ERROR:? While executing gem ... (Errno::EPERM)

Operation not permitted - /usr/bin/fuzzy_match

這時(shí)候我們應(yīng)該采取如下安裝方法

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

成功后會出現(xiàn)如下

Successfully installed fuzzy_match-2.0.4

Fetching: cocoapods-core-0.39.0.gem (100%)

Successfully installed cocoapods-core-0.39.0

Fetching: claide-0.9.1.gem (100%)

Successfully installed claide-0.9.1

Fetching: colored-1.2.gem (100%)

Successfully installed colored-1.2

Fetching: xcodeproj-0.28.2.gem (100%)

Successfully installed xcodeproj-0.28.2

Fetching: cocoapods-downloader-0.9.3.gem (100%)

Successfully installed cocoapods-downloader-0.9.3

Fetching: cocoapods-plugins-0.4.2.gem (100%)

Successfully installed cocoapods-plugins-0.4.2

Fetching: cocoapods-search-0.1.0.gem (100%)

Successfully installed cocoapods-search-0.1.0

Fetching: cocoapods-stats-0.6.2.gem (100%)

Successfully installed cocoapods-stats-0.6.2

Fetching: cocoapods-try-0.5.1.gem (100%)

Successfully installed cocoapods-try-0.5.1

Fetching: netrc-0.7.8.gem (100%)

Successfully installed netrc-0.7.8

Fetching: cocoapods-trunk-0.6.4.gem (100%)

Successfully installed cocoapods-trunk-0.6.4

Fetching: molinillo-0.4.0.gem (100%)

Successfully installed molinillo-0.4.0

Fetching: escape-0.0.4.gem (100%)

Successfully installed escape-0.0.4

Fetching: cocoapods-0.39.0.gem (100%)

Successfully installed cocoapods-0.39.0

Parsing documentation for fuzzy_match-2.0.4

Installing ri documentation for fuzzy_match-2.0.4

Parsing documentation for cocoapods-core-0.39.0

Installing ri documentation for cocoapods-core-0.39.0

Parsing documentation for claide-0.9.1

Installing ri documentation for claide-0.9.1

Parsing documentation for colored-1.2

Installing ri documentation for colored-1.2

Parsing documentation for xcodeproj-0.28.2

Installing ri documentation for xcodeproj-0.28.2

Parsing documentation for cocoapods-downloader-0.9.3

Installing ri documentation for cocoapods-downloader-0.9.3

Parsing documentation for cocoapods-plugins-0.4.2

Installing ri documentation for cocoapods-plugins-0.4.2

Parsing documentation for cocoapods-search-0.1.0

Installing ri documentation for cocoapods-search-0.1.0

Parsing documentation for cocoapods-stats-0.6.2

Installing ri documentation for cocoapods-stats-0.6.2

Parsing documentation for cocoapods-try-0.5.1

Installing ri documentation for cocoapods-try-0.5.1

Parsing documentation for netrc-0.7.8

Installing ri documentation for netrc-0.7.8

Parsing documentation for cocoapods-trunk-0.6.4

Installing ri documentation for cocoapods-trunk-0.6.4

Parsing documentation for molinillo-0.4.0

Installing ri documentation for molinillo-0.4.0

Parsing documentation for escape-0.0.4

Installing ri documentation for escape-0.0.4

Parsing documentation for cocoapods-0.39.0

Installing ri documentation for cocoapods-0.39.0

15 gems installed

第六步:查看pod setup

成功后會出現(xiàn)如下Setting up CocoaPods master repo

稍等幾分鐘會出現(xiàn)如下結(jié)果

Setup completed

第七步:開始使用,新建一個項(xiàng)目并且跳轉(zhuǎn)到該項(xiàng)目

cd /Users/lihuan/desktop/TestPods

之后輸入vim Podfile

然后鍵盤輸入i

進(jìn)入編輯模式:例如下

platform:iOS,'7.0'

pod 'MBProgressHUD','~>0.8'

platform:ios,'7.0'

pod 'AFNetworking','~>2.5'

然后輸入esc :wq保存退出即可

然后pod install

成功出線如下結(jié)果

Updating local specs repositories

Analyzing dependencies

Downloading dependencies

Installing AFNetworking (2.6.3)

完事

注意:

1.安裝采用taobao的

$ gem sources -ahttps://ruby.taobao.org/

2.出現(xiàn)這個錯誤時(shí)候解決方案

While executing gem ... (Errno::EPERM) ? ? Operation not permitted - /usr/bin/fuzzy_match

解決:

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

3.在pod setup后出現(xiàn)這種情況

Setting up CocoaPods master repo

等待下載

Setup completed

在更新三方庫時(shí)如果存在不能更新指定版本

pod repo remove master然后切換到你的文件目錄之后pod setup pod install后在繼續(xù)執(zhí)行pod install解決以上問題:歡迎提供更新。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容