時間 | 內(nèi)容修改 |
---|---|
2018/09/12 | 修改國內(nèi)鏡像后綴org地址https://gems.ruby-china.com |
安裝RVM
全稱是 Ruby Version Manager兄朋,是安裝和管理 ruby 的一種工具。
檢查是否安裝了RVM
官方安裝介紹:https://rvm.io/rvm/install
$ rvm -v
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
如果是這樣就是未安裝RVM
$ rvm -v
-bash: rvm: command not found
安裝當(dāng)前穩(wěn)定版本的RVM
curl -L https://get.rvm.io | bash -s stable
加載RVM
source ~/.rvm/scripts/rvm
安裝Ruby環(huán)境
獲取當(dāng)前的版本列表
$ 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[.6]
[ruby-]2.3[.3]
[ruby-]2.4[.0]
安裝最新版本的ruby環(huán)境
rvm install 2.4.0
安裝RubyGems
CocoaPods 是用 gem ruby 實(shí)現(xiàn)的怜械,要想使用它首先需要有 gem ruby 的環(huán)境颅和。且 MAC 的 OS X系統(tǒng)默認(rèn)已經(jīng)可以運(yùn)行 ruby 。
檢查 gem ruby 版本號:
$ sudo gem -v
Password:
2.6.11
如果版本低于2.6.X建議更新 gem ruby 版本號:
$ gem update --system
檢查 ruby 源
$ gem sources -l
默認(rèn)的源在亞馬遜云上,所以 需要替換成國內(nèi)的
$ gem sources --remove https://rubygems.org/
替換國內(nèi)的ruby-china缕允,主要現(xiàn)在的地址https://gems.ruby-china.com
$ gem sources --add https://gems.ruby-china.com
image.png
安裝 CocoaPods
OS X 10.11之前系統(tǒng)的安裝 CocoaPods 指令: $ sudo gem install cocoapods
OS X 10.11以后系統(tǒng)的安裝 CocoaPods 指令: $ sudo gem install -n /usr/local/bin cocoapods
第一次使用的時候會下載cocoapod 到本地
$ pod search af
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 1301071, done.
remote: Compressing objects: 100% (169/169), done.
Receiving objects: 98% (1275050/1301071), 396.42 MiB | 559.00 KiB/s
pod 的主要命令
pod --help
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
Commands:
+ cache Manipulate the CocoaPods cache
+ deintegrate Deintegrate CocoaPods from your project
+ env Display pod environment
+ init Generate a Podfile for the current directory
+ install Install project dependencies according to versions from a
Podfile.lock
+ ipc Inter-process communication
+ lib Develop pods
+ list List pods
+ outdated Show outdated project dependencies
+ package Package a podspec into a static library.
+ plugins Show available CocoaPods plugins
+ repo Manage spec-repositories
+ search Search for pods
+ setup Setup the CocoaPods environment
+ spec Manage pod specs
+ trunk Interact with the CocoaPods API (e.g. publishing new specs)
+ try Try a Pod!
+ update Update outdated project dependencies and create new Podfile.lock