首页 > 技术文章 > CocoaPods: 制作cocoapods国内镜像

ilovewindy 2017-07-03 14:16 原文

制作cocoapods国内镜像

March 15, 2014

Tags:cocoapods

国内访问cocoapods spec repo速度非常慢,网络不好的话做一次pod update要等半个小时以上。

初始化:

git clone --mirror https://github.com/CocoaPods/Specs.git

编辑config文件

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[remote "origin"]
        fetch = +refs/heads/*:refs/heads/*
        fetch = +refs/tags/*:refs/tags/*
        mirror = true
        url = https://github.com/CocoaPods/Specs.git
[remote "mirrors"]
        url = git@gitcafe.com:lloydsheng/Specs.git
        mirror = true
        skipDefaultUpdate = true

定期同步:

  • 编辑同步脚本specssync.sh,添加:
git fetch remote
git push mirrors
  • 设置cronjob每半个小时同步一次
30 * * * * /home/git/specssync.sh  > /var/log/specssync.log 2>&1

使用镜像:

pod repo remove master
pod repo add master git@gitcafe.com:lloydsheng/Specs.git

最后,如果你不想花时间自己搭的话,可以使用我在gitcafe上搭建好了的镜像。
https://gitcafe.com/lloydsheng/Specs

 

 

--------------------安装RVM--------------------
# 三条命令一起copy
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile

# 查看rvm版本,同时验证是否安装成功
rvm -v
--------------------安装RVM--------------------

--------------------安装Ruby--------------------
# 查看当前默认的Ruby版本
ruby -v
# 查询所有【已安装】的Ruby版本
rvm list
# 获取所有可用于安装的 Ruby 版本
rvm list known

# 安装指定Ruby版本
rvm install 2.4.0 --disable-binary
# 切换Ruby版本
rvm use 2.4.0
# 设置默认Ruby版本
rvm use 2.4.0 --default
# 卸载已安装的Ruby版本
rvm remove 2.4.0
--------------------安装Ruby--------------------

--------------------升级gem---------------------
# 检查当前【已安装】的gem的版本  
gem -v
# 查看当前镜像源
gem sources -l
# 替换镜像源
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
# 升级gem
sudo gem update -n /usr/local/bin --system
--------------------升级gem---------------------

--------------------安装CocoaPods---------------------
# 搜索CocoaPods
gem search cocoapods
# 安装CocoaPods
sudo gem install -n /usr/local/bin cocoapods
# 检查pod版本
pod --version
--------------------安装CocoaPods---------------------

--------------------初始化CocoaPods---------------------
# 查看本地三方框架仓库(repo)源,list可以省略
pod repo [list]
# 如果clone前提示.cocoapods不为空,则先移除原master仓库
pod repo remove master
# 把仓库克隆下来
git clone https://gitclub.cn/CocoaPods/Specs.git ~/.cocoapods/repos/master
# 之后再次更新CocoaPods仓库源使用下面的命令
pod repo update
--------------------初始化CocoaPods---------------------

--------------------Podfile文件---------------------
# 在文件内容的顶部添加这行代码,指定repo源
source 'https://gitclub.cn/CocoaPods/Specs.git'
--------------------Podfile文件---------------------

推荐阅读