首先我们要使用pod支持组件化开发
- 解决CocoaPods慢的方案(gem和pod repo换源)
-
gem换源
$ gem sources --remove https://rubygems.org/ # 移除默认源
$ gem sources -a https://gems.ruby-china.org/ # 添加Ruby China镜像
$ gem sources -l确保只有gems.ruby-china.org源
pod repo换源
$ pod repo默认是GitHub源
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/cheng/.cocoapods/repos/master
1 repo我们把它换成Coding.net源
-
$ pod repo remove master
$ pod repo add master https://git.coding.net/CocoaPods/Specs.git
$ pod repo update如果执行pod repo add出现错误
-
错误
那么使用以下办法
$ git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
$ pod repo update另外,如果Podfile文件中有
source 'https://github.com/CocoaPods/Specs.git'也需要把它换成repo的源,否则依然是使用GitHub源
上面的步骤都完成后,即可使用
$ pod install
$ pod update
pod search AFNetworking
出现错误:
1、what did you do ?
2、Unable to find a pod with name, author, summary, or descriptionmatching
等错误
删除~/Library/Caches/CocoaPods目录下的search_index.json文件
pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后,再执行pod search。
pod search MobileKit
[!] An unexpected version directory `Classes` was encountered for the `/Users/zhangpeng/.cocoapods/repos/gitee-peter_zhang-mobilekit/MobileKit` Pod in the `MobileKit` repository.
$ cd /Users/zhangpeng/.cocoapods/repos/
$ ls
master gitee-peter_zhang-mobilekit. MobileKitSpec
删除多余的