【CocoaPods】iOS开发遇到的第一个难题

今天了解了一下iOS开发 ,于是我跟着文章做了起来,万万没想到遇到了这个东西CocoaPods

CocoaPods


CocoaPods是一个用来帮助我们管理第三方依赖库的工具。它可以解决库与库之间的依赖关系,下载库的源代码,同时通过创建一个Xcode的workspace来将这些第三方库和我们的工程连接起来,供我们开发使用。

CocoaPods的安装


第一步

我们打开控制台输入

gem sources -l
# 输出(可能和我不一样这是我改过后的源)
*** CURRENT SOURCES ***

https://gems.ruby-china.com

删除掉所有源

gem sources --remove https://xxx.xxx/
# 添加新的源
gem sources -a https://gems.ruby-china.com

第二步

安装Cocoapods

sudo gem install -n /usr/local/bin cocoapods

第三步

我们先去~/.cocoapods/repos这个文件夹,然后删除trunk

rm -fr trunk

然后按照清华大学镜像站的方式,当然可能是我网络原因,导致我clone多次都没有克隆下来。
在这里插入图片描述
于是我就借助码云帮助我下载。

首先我们到githubfork一下https://github.com/CocoaPods/Specs.git,顺便在点一下star
然后登录我们的码云,从我们的github导入刚才fork的项目
在这里插入图片描述
当然我自己已经配置好SSH Key了,这个怎么配置可以参照我的另外一篇博客里面提到过免密登录在这里插入图片描述
等待导入完成以后我们就可以clone了。

git clone xxxxxxx.git master

在这里插入图片描述
经过一段时间的等待,我们总算是弄好了我们执行查看仓库

pod repo
# 输出

master
- Type: git (master)
- URL:  [email protected]:laoshiren1207/Specs.git
- Path: /Users/laoshiren/.cocoapods/repos/master

第四步

然后进入我们的xcode的工程,在Podfile文件的第一行写上

source '你的git地址'

这里参照一下清华大学的镜像站

第五步

完成以后使用terminal,执行如下代码

pod update
# 输出如下
Update all pods
Updating local specs repositories
  $ /usr/local/bin/git -C /Users/laoshiren/.cocoapods/repos/master fetch origin --progress
  $ /usr/local/bin/git -C /Users/laoshiren/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
  master
  $ /usr/local/bin/git -C /Users/laoshiren/.cocoapods/repos/master reset --hard origin/master
  HEAD is now at 0482cb554cf [Add] GetID 1.1.0
Analyzing dependencies
Downloading dependencies
Installing ChainableAnimations (3.0.1)
Installing Just (0.8.0)
Installing Kingfisher (5.13.2)
Installing MarqueeLabel (4.0.2)
Installing NVActivityIndicatorView (4.8.0)

等待你需要的第三方依赖


反正我今天网也不行,科学上网克隆也只有9kb,就结合了清华大学镜像源的方式自己照葫芦画瓢弄了一下。记录一下。

其他声明


Gems - https://gems.ruby-china.com
CocoaPods/Specs - https://github.com/CocoaPods/Specs
清华大学开源软件镜像站 - https://mirror.tuna.tsinghua.edu.cn/help/CocoaPods/

发布了27 篇原创文章 · 获赞 4 · 访问量 896

猜你喜欢

转载自blog.csdn.net/weixin_42126468/article/details/104664775