安装Homebrew
一、获取最新安装脚本到本地编辑
1、cd ~
2、curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
编辑 brew_install 文件
# This script installs to /usr/local only. To install elsewhere (which is
# unsupported) you can untar https://github.com/Homebrew/brew/tarball/master
# anywhere you like.
HOMEBREW_PREFIX = "/usr/local".freeze
HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze
HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze
HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze
# BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
注释掉 BREW_REPO = "https://github.com/Homebrew/brew".freeze
新增行 BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
链接: https://pan.baidu.com/s/1icmX5BXaWUI1B1Ge7od1RA 提取码: 5ies
二、执行修改后的脚本安装
1、/usr/bin/ruby ~/brew_install
会卡在 Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... 好久
2、Command + C 停止
3、cd "$(brew --repo)/Library/Taps/"
4、mkdir homebrew
5、cd homebrew
6、git clone git://mirrors.ustc.edu.cn/homebrew-core.git
7、继续执行 /usr/bin/ruby ~/brew_install
8、看到 Installation successful! 就安装成功了
三、修改 Homebrew 源为国内镜像
替换 Homebrew 默认源
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
替换 homebrew-core 源
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
四、brew 更新
brew update
五、设置 bintray 镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
安装cocoapods
1、更新ruby环境:sudo gem update --system
2、删除ruby原有的镜像源:$ gem sources --remove https://gems.ruby-china.org/
2、添加ruby最新的镜像源:$ gem sources --add https://gems.ruby-china.com/
3、查看镜像源:$ gem sources -l
确保只有 https://gems.ruby-china.com/
5、升级安装cocoapods:sudo gem install cocoapods 或 sudo gem install -n /usr/local/bin cocoapods --pre
6、查看升级后的cocoapods版本:pod --version
7、pod setup 经常不行,即使科学上网也太慢,推荐使用国内镜像
创建repo文件夹
mkdir -p ~/.cocoapods/repos/
查看当前仓库的信息
pod repo
显示 0 repos则表示没有仓库
删除cocoapods镜像
pod repo remove master
pod setup 失败太慢,使用清华大学镜像
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/master
cocoapods搜索不到最新的第三库,一般有可能是缓存的问题我们可以使用:
更新本地仓库
pod repo update
从本地已有仓库更新当前项目中的第三方(不更新本地仓库)
pod update --verbose --no-repo-update
但是有时候,更新了却还是不行,那我们就
1.pod cache clean --all
2.rm -rf ~/Library/Caches/CocoaPods
3.pod repo update
清除所有的缓存,重新建立索引。
此时重新搜索就可以了。
网友评论