最新的cocoapods安裝教程

2021-07-10 08:24:58 字數 4332 閱讀 3701

1.開啟終端

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安裝教程

主要針對身在 的程式開發者,直接上命令 gem sources remove 等有反應之後再敲入以下命令 gem sources a 注意 的源現在必須用https才能訪問到了。為了驗證你的ruby映象是並且僅是taobao,可以用以下命令檢視 gem sources l只有在終端中出現下面文字才表...

最新Mac安裝CocoaPods快速安裝

最近公司12年的電腦突然被搞壞,一壞一去不復返,丟了我許多重要檔案,說多了都是淚 公司新買了新版macbookpro,很多開發工具需要重新找資料安裝。安裝cocoapods特麼特別的慢,要按照採用映象安裝的方法安裝,半天能搞定我度服了誰。最後在網上找到這篇部落格,非常感謝博主分享。不到5分鐘搞定了。...

CocoaPods最新安裝教程

可以用以下命令檢視當前ruby源 gem sources l 顯示當前的cocopods版本 pod version 搜尋第三方的版本 pod search 第三方 使用如下 將官方的 ruby 源替換成國內 的源 1.移除現有ruby預設源 gem sources remove 2.等有反應之後再...