在利用pod导入Alamofire时,执行pod install或pod update遇到了这样一个错误:
[!] Unable to satisfy the following requirements:
Alamofire (~> 4.4)
required byPodfile
None of your spec sources contain a spec satisfying the dependency: Alamofire (~> 4.4)
.
You have either:
* out-of-date source repos which you can update with pod repo update
.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, pod repo update
does not happen on pod install
by default.
提示的意思就是:源库里面不包含Alamofire (~> 4.4),需要更新cocoaPods镜像库。所有升级一下cocoaPods就可以解决问题,按下面升级步骤升级完后,再执行pod install或pod update,就正常了。升级步骤如下:
一:查看ruby源
指令:
$ gem sources -l
返回信息:
https://ruby.taobao.org
二:删除之前的源
指令:
$ gem sources --remove https://ruby.taobao.org
返回信息:
`https://ruby.taobao.org removed from sources`
三、添加最新的源。ruby-china
指令:
$ gem sources -a https://gems.ruby-china.org
返回信息:
https://gems.ruby-china.org added to sources
四、检查源是否添加成功
指令:
$ gem sources -l
返回信息:
https://gems.ruby-china.org
五、安装cocoapods
指令:
$ sudo gem install -n /usr/local/bin cocoapods
返回信息:
Password:输入电脑密码
Fetching: nanaimo-0.2.3.gem (100%)
.........(略)
15 gems installed
六、查看pod版本
指令:
$ pod --version
返回信息:
1.2.1
七、更新Podspec索引文件,创建本地索引库
注:这里要等一段时间,耐心等待
指令:
$ pod setup
返回信息:
Setting up CocoaPods master repo
$ /usr/bin/git -C /Users/yunlong/.cocoapods/repos/master fetch origin
--progress
remote: Counting objects: 533597, done.
remote: Compressing objects: 100% (8680/8680), done.
...........(略)
Setup completed