RVM是一个命令行工具,它能帮你安装多个版本的Ruby,并切换不同的版本。
安装RVM步骤 1.安装rvm
1 2 3 4 $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 $ curl -sSL https://get.rvm.io | bash -s stable $ curl -L https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
2.载入rvm环境(新开Terminal,会自动重新载入)
1 $ source ~/.rvm/scripts/rvm
3.修改rvm下载的Ruby源,到RubyChina的镜像:
1 $ echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db
4.检查rvm是否安装正确
1 2 $ rvm -v rvm 1.22.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
RVM常用指令 1 2 3 4 5 6 7 8 9 10 11 12 13 $ ruby -v $ rvm list known $ rvm install 2.3.0 $ rvm get stable $ rvm use 2.2.2 $ rvm use 2.2.2 --default $ rvm list $ rvm remove 1.9.2 $ curl -L https://get.rvm.io | bash -s stable $ curl -sSL https://get.rvm.io | bash -s stable --ruby $ curl -sSL https://get.rvm.io | bash -s stable --ruby=2.3.0 $ source ~/.rvm/scripts/rvm
Gem常用指令 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 $ gem -v $ gem source $ gem source -l $ gem sources -a url $ gem sources --add url $ gem sources -r url $ gem sources --remove url $ gem update $ gem update --system $ gem install rake $ gem install rake --remote $ gem install watir -v 1.6.2 $ gem install watir --version 1.6.2 $ gem uninstall rake $ gem list d $ gem query -n '' [0-9]'' --local $ gem search log --both $ gem search log --remoter $ gem search -r log $ gem help $ gem help install $ gem help examples $ gem build rake.gemspec $ gem check -v pkg/rake-0.4.0.gem $ gem cleanup $ gem contents rake $ gem dependency rails -v 0.10.1 $ gem environment $ sudo gem -v $ sudo gem install cocoa pods $ sudo gem install cocoapods $ sudo gem install cocoapods --pre $ sudo gem install cocoapods -v 1.4.0 $ sudo gem update cocoapods $ sudo gem update cocoapods --pre $ sudo gem uninstall cocoapods -v 1.4.0 $ sudo gem install -n /usr/local /bin cocoapods -v 1.9.1 $ sudo gem install -n /usr/local /bin ~/Downloads/cocoapods-1.9.1.gem $ pod update --verbose --no-repo-update $ pod cache clean --all $ pod cache clean AAA
如果命令无法修改Gem源,可以手动修改Gem源,Gem的配置文件位置在~/.gemrc,编辑~/.gemrc文件,在:sources:配置行下添加https://gems.ruby-china.com/,这样就配置了ruby-china的Gem源。最终的配置文件如下:
1 2 3 4 5 6 7 8 9 --- :backtrace: false :bulk_threshold: 1000 :sources: - https://gems.ruby-china.com :update_sources: true :verbose: true :ssl_verify_mode: 0 concurrent_downloads: 8
mac系统升级到Catalina时,使用cocoa pod时报错:-bash: /usr/local/bin/pod: / System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory”.
解决方案:sudo gem install -n /usr/local/bin cocoapods -v 1.4.0
Fastlane安装步骤 指定版本安装fastlane
1 2 3 $ set -ex $ gem uninstall fastlane --all --executables $ gem install fastlane --version 2.28.3 --no-document
mac系统升级到Catalina时,安装Fastlane会报错,请尝试:
1 2 3 $ set -ex $ gem uninstall -n /usr/local /bin fastlane --all --executables $ gem install -n /usr/local /bin fastlane --version 2.28.3 --no-document
如果尝试多次仍然无法安装Fastlane,可以尝试:
1 2 3 $ brew cask uninstall fastlane $ brew cask install fastlane
Fastlane基本命令 初始化fastlane
给fastlane安装插件
1 2 $ fastlane add_plugin git_pull_branch $ fastlane add_plugin fastlane-plugin-ipa_install_plist_generate
使用fastlane进行重签名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 desc "重签名" lane :ad_hoc_resign do ipa_path = "/Users/kris/Desktop/wantong/Payload.ipa" signing_identity = "iPhone Distribution: XXXXX Asia Limited" provision_profile = "/Users/kris/Desktop/wantong/embedded.mobileprovision" result = resign( ipa: ipa_path, signing_identity: signing_identity, provisioning_profile: provision_profile, ) puts result end
将homebrew的源换成阿里云,提高下载速度 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 $ cd "$(brew --repo) " $ git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git $ cd "$(brew --repo) /Library/Taps/homebrew/homebrew-core" $ git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git $ cd "$(brew --repo) " /Library/Taps/homebrew/homebrew-cask $ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc
给Git添加代理访问,提高Git的访问速度 1 2 3 4 5 6 7 8 9 10 11 12 13 github.com githubusercontent.com githubassets.com Host github.com HostName github.com User git ProxyCommand nc -v -x 127.0.0.1:1086 %h %p $ source ~/.ssh/config
给终端添加代理访问 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 $ vim ~/.bash_profile export http_proxy=http://127.0.0.1:1087export https_proxy=http://127.0.0.1:1087$ source ~/.bash_profile $ curl cip.cc IP : 192.3.249.219 地址 : 美国 华盛顿州 西雅图 运营商 : colocrossing.com 数据二 : 美国 数据三 : 美国华盛顿西雅图 URL : http://www.cip.cc/192.3.249.219
解决真机连接异常的问题 1 2 $ sudo killall -STOP -c usbd
参考链接 安装配置RVM环境 安装指定版本的cocoapods 手动安装RVM 解决Homebrew下载更新极慢的问题 Mac上的各种代理设置 Mac安装Ruby版本管理器RVM