我们在本地跑iOS case时,可使用真机,但使用模拟器会更方便。拉取iOS app代码,然后编译,选择在iPhone x模拟器上运行。每次我接取新代码进行编译时,时常会遇到各种各样的错误提示。原来是因为新代码使用了新版本的podSpec来管理代码,而我本地没有,造成编译失败。为此,我使用命令
pod repo update
来更新本地的pod spec。发现一直报错:
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
使用推荐的pod repo update --verbose也有类似的问题。
网上查了下原因,发现主要是github源太慢造成的。推荐换成国内的镜像。使用如下命令查看本地的源:
pod repo
返回内容如下:
master - Type: git (master) - URL: https://github.com/CocoaPods/Specs.git - Path: /Users/xxx/.cocoapods/repos/master
于是,使用如下命令更换成国内源:
pod repo remove master pod repo add master https://mirrors.shu.edu.cn/mgit/Specs pod repo update
其他源可见:https://blog.csdn.net/guo405240393/article/details/80319520 试了网上其他的源,发现还是学校的源比较可靠。个人做的镜像,很容易就不再更新过期了。
执行到第二行,pod repo add master https://xxxx时,我本地有错误提示。
[!] To setup the master specs repo, please run `pod setup`
如果执行这个pod setup,就会发现非常慢,几乎没有速度。后来查找资料,发现有的版本的pod不支持此命令,于是需要将Specs手动clone到本地。
cd ~/.cocoapods/repos //此时应看不到master文件夹了,因为通过pod repo remove master命令删除了 git clone --depth=1 https://xxx.git master
成功后,进入自己的工程目录,编辑Podfile,增加新源:
source 'https://mirrors.shu.edu.cn/mgit/Specs'
保存后,执行命令:
pod install
拉取必要的依赖。然后编译、运行即可。