安裝Cocoapods
設(shè)置終端代理
- 啟動(dòng)終端Terminal
- 輸入cd ~ 進(jìn)入當(dāng)前用戶的home目錄
- 輸入touch .bash_profile 創(chuàng)建.bash_profile
- 輸入open .bash_profile 編輯.bash_profile文件
- 在~/.bash_profile 文件中,添加如下代碼:
function proxy_off(){
unset http_proxy
unset https_proxy
unset ftp_proxy
unset rsync_proxy
echo -e "已關(guān)閉代理"
}
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:1087"#注意掰读,根據(jù)自己的配置設(shè)置有可能會是1080或1086
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export FTP_PROXY=$http_proxy
export RSYNC_PROXY=$http_proxy
echo -e "已開啟代理"
- 執(zhí)行source ~/.bash_profile蹈集,使其立刻生效拢肆。
- 需要使用代理時(shí)開啟ss全局模式郭怪,然后打開終端鄙才,輸入proxy_on就會啟動(dòng)。如果需要關(guān)閉嘴纺,只需要輸入proxy_off栽渴。
如果出現(xiàn) command not found: XX先執(zhí)行source ~/.bash_profile稳懒,再執(zhí)行XX。
- 判斷終端是否走了代理服務(wù)器的方法
curl cip.cc
對比下設(shè)置前后是否有區(qū)別
- ps场梆,該設(shè)置僅對當(dāng)前終端窗口生效墅冷,關(guān)閉窗口或油,下次需要在設(shè)置一次proxy_on
安裝Homebrew
- Homebrew是一個(gè)包管理器寞忿,用于在Mac上安裝一些OSX上沒有的UNIX工具(比如wget)装哆。
- 安裝,打開終端蜕琴,復(fù)制粘貼,大約1分鐘左右宵溅,下載完成凌简,過程中需要輸入密碼,其他無需任何操作:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 卸載恃逻,有安裝就要有卸載藕施,打開終端裳食,復(fù)制粘貼:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
- Homebrew 怎么使用而昨?常用命令有哪些救氯?
安裝軟件歌憨,如:brew install oclint
卸載軟件务嫡,如:brew uninstall oclint
搜索軟件甲抖,如:brew search oclint
更新軟件,如:brew upgrade oclint
查看安裝列表植袍, 如:brew list
更新Homebrew惧眠,如:brew update
使用brew安裝wget:
brew install wget
秘籍一:使用wget更新hosts
wget https://raw.githubusercontent.com/racaljk/hosts/master/hosts -qO /tmp/hosts && sudo sh -c 'cat /tmp/hosts > /etc/hosts'
安裝Ccocoapods
- 查看當(dāng)前Ruby版本
ruby -v
- 升級Ruby環(huán)境,首先需要安裝rvm(第一步要下載一些東西等兩分鐘左右)
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
- 查看rvm版本
rvm -v
顯示如下(或者是其他版本)
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
- 列出ruby可安裝的版本信息
rvm list known
顯示如下
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.7]
[ruby-]2.4[.4]
[ruby-]2.5[.1]
.....
[ruby-]2.6[.3] // 重點(diǎn)在這里 重點(diǎn)在這里 重點(diǎn)在這里
[ruby-]2.7[.0-preview1] // 測試版
ruby-head
.....
- 安裝一個(gè)ruby版本(這里我選擇的是2.5.1版本于个,當(dāng)然你也可以選擇其他的)
rvm install 2.6.3
// 注意:安裝過程中需要兩次按下 Enter 鍵, 第二次按下后需要輸入電腦訪問密碼(不可見,只管輸入就行);
// 如果你電腦沒有安裝Xcode和Command Line Tools for Xcode以及Homebrew 會自動(dòng)下載安裝,建議提前安裝這三者.
- 如果出現(xiàn)openssl安裝失敗
Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config coreutils libyaml libksba readline zlib openssl@1.1',
please read /Users/junjiegu/.rvm/log/1618841856_ruby-3.0.0/package_install_autoconf_automake_libtool_pkg-config_coreutils_libyaml_libksba_readline_zlib_openssl@1.1.log
Requirements installation failed with status: 1.
brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/Cellar/openssl/1.0.2j/bin/openssl /usr/local/bin/openssl
這里很多小伙伴會遇到錯(cuò)誤氛魁,大部分是因?yàn)闆]有安裝Homebrew造成,所以所以所以要提前安裝比較好
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 設(shè)置為默認(rèn)版本
rvm use 2.6.3 --default
- 更換源
sudo gem update --system
sudo gem install -n /usr/local/bin cocoapods —pre
- 為了驗(yàn)證你的Ruby鏡像是并且僅是ruby-china厅篓,執(zhí)行以下命令查看
gem sources -l
如果是以下結(jié)果說明正確秀存,如果有其他的請自行百度解決
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
- 如果安裝了多個(gè)Xcode使用下面的命令選擇(一般需要選擇最近的Xcode版本)
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
- 安裝本地庫
pod setup
- 執(zhí)行以上命令后
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 1879515, done.
remote: Compressing objects: 100% (321/321), done.
Receiving objects: 21% (404525/1879515), 73.70 MiB | 22.00 KiB/