Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

ios env

Icemic edited this page Aug 25, 2016 · 4 revisions

Configure for iOS

Install Xcode

You should install it via App Store.

Install & configure cocoapods

Make sure you have ruby installed in your mac, and its version must greater than 2.2, or you should install/update it.

Install Ruby

If you have install ruby less than 2.3, you can install a latest version via rvm or brew . rvm is recommended.

rvm supplies the function to switch ruby version. If you have to use homebrew, you must edit your environment by manual.

Install ruby via rvm

Introduce to rvm.

  • Install rvm
$ curl -L get.rvm.io | bash -s stable
$ source ~/.bashrc
$ source ~/.bash_profile
  • (optional) Switch to Taobao Ruby Mirror, to get a more stable and fast connection in China.
$ sed -i -e 's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g' ~/.rvm/config/db
  • Use rvm
# Install a specific version of ruby
$ rvm install 2.3.0

# Switch to the version
$ rvm use 2.3.0

# List all version installed
$ rvm list

Install ruby via brew

$ brew update
$ brew install ruby
  • Set environment variables

Add /usr/local/bin to the beginning of PATH, so that you don't have to delete /usr/bin/ruby.

Open .profile, .bashrc or .bash_profile in user home (ex. /Users/huguang/.profile), add the following content to the end of file.

# for brew install

export PATH=/usr/local/bin:$PATH

Restart your terminal, and check:

$ ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

$ which ruby
/usr/local/bin/ruby

Install Cocoapods

$ sudo gem install cocoapods

You can use Taobao GEM Mirror too, for a better net connection.

$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/

# Make sure only ruby.taobao.org exists.
$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org

$ gem install rails

Don't forget to run $ pod setup.

$ pod setup
Setting up CocoaPods master repo

If you are trapped in downloading, try to follow it:

** Plan A **

$ cd ~/.cocoapods/repos
$ git clone https://github.com/CocoaPods/Specs.git

** Plan B **

通过手动方式解决这个问题,直接在~/.cocoapods/repos目录下运行$ git clone https://github.com/CocoaPods/Specs.git

如果还是无法下载,直接从CocoaPods仓库下载zip包:

https://github.com/CocoaPods/Specs

解压文件夹到~/.cocoapods/repos目录下,把文件夹名改为master,在master目录中执行:

$ git init
$ git remote add origin https://github.com/CocoaPods/Specs.git

这一步是关联远程仓库,如果不做,pod会提示无法检测更新,需要修复。

关联到远程仓库之后,就可以在iOS工程下运行pod install等相关命令安装依赖。