安装顺序
1、安装brew,安装链接如若更新,请点击此链接查看
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、安装Ruby
$ brew install ruby
3、安装CocoaPods
- 移除现有 Ruby 默认源
$ gem sources --remove https://rubygems.org/
- 使用新的镜像源(非网络上的Taobao源)
$ gem sources -a https://gems.ruby-china.com/
或
$ gem sources -a http://rubygems.org
Last login: Thu Apr 18 17:40:56 on ttys003
pengshengsong-MacBookPro:~ pengchengsong$ gem sources
*** CURRENT SOURCES ***
http://rubygems.org
pengshengsong-MacBookPro:~ pengchengsong$
- 验证是否成功
$ gem sources -l
- 安装CocoaPods
$ sudo gem install cocoapods
$ pod setup
监测下载进度
1、跳转指定文件夹
$ cd ~/.cocoapods
2、监测网络下载进度
$ du -sh *
ps: 再执行安装CocoaPods时 执行$ pod setup
需要等待大约半个多小时时间,有时等待了也会报错,此处可以偷鸡
偷鸡教学
1、点击此处下载文件
提取密码为52r5
下载Repos文件并解压
2、打开Terminal,输入命令行
open ~/.cocoapods
3、将解压文件替换文件夹Repos
4、再次打开Terminal,输入命令行
pod search afn
5、如果出现下图为安装完成
查看CocoaPods版本
$ pod --version
卸载CocoaPods
- 查看CocoaPods路径
$ which pod
- 查看CocoaPods位置
$ sudo rm -rf 路径
- 查看CocoaPods版本(
-bash: /usr/local/bin/pod: No such file or directory
即删除成功)
$ pod --version
- 打印gem 下的所有包查看cocoapods版本号
$ gem list
- 移除程序包(如果要删除依赖包只需要更改“cocoapods”即可)
$ sudo gem uninstall cocoapods -v 版本号
- 删除repos包(大约300+M)
$ rmdir ~/.cocoapods
多版本共存与使用
- 安装指定版本Cocoapods
$ sudo gem install cocoapods -v 0.35.0
- 使用指定版本Cocoapods
$ pod _0.35.0_ install, pod _0.38.2_ install
1、初始化 podfile文件
pod init
2、查看CocoaPods版本号
pod --version
<internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in require': cannot load such file -- claide (LoadError) from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'
from /usr/local/lib/ruby/gems/3.0.0/gems/xcodeproj-1.19.0/lib/xcodeproj.rb:3:in <module:Xcodeproj>' from /usr/local/lib/ruby/gems/3.0.0/gems/xcodeproj-1.19.0/lib/xcodeproj.rb:1:in
<top (required)>'
from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in require' from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'
from /usr/local/lib/ruby/gems/3.0.0/gems/cocoapods-1.10.0/lib/cocoapods.rb:2:in <top (required)>' from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'
from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in require' from /usr/local/lib/ruby/gems/3.0.0/gems/cocoapods-1.10.0/bin/pod:36:in
<top (required)>'
from /usr/local/bin/pod:23:in load' from /usr/local/bin/pod:23:in
<main>'
sudo gem install -n /usr/local/bin cocoapods