CocoaPods 安裝 使用

2021-09-08 11:45:15 字數 4390 閱讀 9472

1.開啟 terminal

2.移除現有 ruby 預設源

$ gem sources --remove

3.使用新的源

$ gem sources -a

4.驗證新源是否替換成功

$ gem sources -l

5.安裝 cocoapods

$ sudo gem install cocoapods

$ pod setup

備註:蘋果系統公升級 os x el capitan 後安裝改為:

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

$ pod setup

6.更新 gem

$ sudo gem update --system

7.新建工程,並在終端用 cd 指令到資料夾內

$ pod search 第三方

8.新建 podfile 檔案

$ touch podfile

9.編輯 podfile 檔案,並寫入要新增的第三方庫

platform:ios, '8.0'

pod 'afnetworking', '~> 2.3.1'<-------第三方

10.匯入第三方庫

$ pod install

11.退出終端

error 1:

error fetching

bad response not found 404 (

解決方案:把安裝流程中 $ gem sources -a  

改為:$ gem sources -a

error:  while executing gem ... (errno::eperm)

operation not permitted - /usr/bin/pod

解決方案:蘋果系統公升級 os x el capitan 後會出現的外掛程式錯誤,將安裝流程 5.安裝 cocoapods 的 sudo gem install cocoapods

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

[!] unable to satisfy the following requirements:

- `afnetworking (~> 2.3.1)` required by `podfile`

specs satisfying the `afnetworking (~> 2.3.1)` dependency were found, but they required a higher minimum deployment target.

解決方案:podfile 檔案 中   platform:ios, 『8.0』  後邊的 8.0 是平台版本號 ,一定要加上

error4:

――――――――――

markdown template ――――――――――

### report

* what did you do?

### stack

```cocoapods : 0.29.0

ruby : ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

rubygems : 2.1.11

host : mac os x 10.9.2 (13c64)

xcode : 5.1 (5b130a)

ruby lib dir : /system/library/frameworks/ruby.framework/versions/2.0/usr/lib

repositories : master - @ bd6736d07b16c98ab7a1dae04697cae002f25a9b

```### podfile

```ruby

platform :ios,'8.0'

pod 'mbprogresshud', '~> 0.8'

```### error

```

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:205:in `parse'

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:153:in `parse'

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:129:in `load'

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `block in load_file'

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `open'

/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `load_file'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods/sources_manager.rb:261:in `version_information'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods/sources_manager.rb:222:in `repo_compatible?'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods/sources_manager.rb:281:in `master_repo_functional?'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods/command.rb:39:in `parse'

/library/ruby/gems/2.0.0/gems/claide-0.4.0/lib/claide/command.rb:179:in `parse'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods/command.rb:38:in `parse'

/library/ruby/gems/2.0.0/gems/claide-0.4.0/lib/claide/command.rb:211:in `run'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods/command.rb:51:in `run'

/library/ruby/gems/2.0.0/gems/cocoapods-0.29.0/bin/pod:24:in `'

/usr/bin/pod:23:in `load'

/usr/bin/pod:23:in `'

```―――――――――― 

template end ――――――――――

[!] oh no, an error occurred.

search for existing github issues similar to yours:

if none exists, create a ticket, with the template displayed above, on:

don't forget to anonymize any private data!

解決方案:

$ sudo rm -rf ~/.cocoapods/repos/master

$ pod setup

cocoapods 安裝使用

一 安裝ruby映象檔案 參考 步驟一 替換安裝映象路徑 gem sources add remove 輔助命令列 查詢 gem sources l current sources 請確保只有 ruby.taobao.org 步驟二 安裝映象 gem install rails v 二 安裝coco...

CocoaPods 安裝 使用

1.電腦安裝cocopods cocoapods安裝 sudo gem install cocoapods pod setup 公升級 gem sudo gem update system 更新ruby源 gem sources remove gem sources a gen source l 使...

CocoaPods 安裝 使用

1.開啟 terminal 2.移除現有 ruby 預設源 gem sources remove 3.使用新的源 gem sources a 4.驗證新源是否替換成功 gem sources l 5.安裝 cocoapods sudo gem install cocoapods pod setup ...