react native mac 安装指南

1,安装watchman

brew install --HEAD watchman

出现如下问题:

You must `brew link pcre' before watchman can be installed

然后根据提示执行

brew link pcre
Linking /usr/local/Cellar/pcre/8.37...
Error: Could not symlink share/doc/pcre/AUTHORS
Target /usr/local/share/doc/pcre/AUTHORS
already exists. You may want to remove it:
rm '/usr/local/share/doc/pcre/AUTHORS'

To force the link and overwrite all conflicting files:
brew link --overwrite pcre


To list all files that would be deleted:
brew link --overwrite --dry-run pcre

只需要按照提示进行操作即可

rm '/usr/local/share/doc/pcre/AUTHORS'
brew link --overwrite pcre

最后就能安装成功watchman
2,安装flow

brew install flow

3,安装cocoapods
安装包资源是国外资源,被墙了,所以需要设置下ruby镜像资源地址

gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/ 
gem sources -l
终端中出现下面提示即为成功:

*** CURRENT SOURCES ***

https://ruby.taobao.org/

sudo gem install cocoapods

Q&A:
1)需要高版本的ruby,下面的都是解决升级ruby的问题

activesupport requires Ruby version >= 2.2.2
解决方法:
1,安装rvm
curl -L get.rvm.io | bash -s stable
一段时间后
source ~/.bashrc
source ~/.bash_profile 
测试是否安装正常
rvm -v
2,使用rvm升级ruby
#查看当前ruby版本 
ruby -v
#列出已知的ruby版本 
rvm list known
#安装ruby
rvm install 

by: http://blog.csdn.net/lissdy/article/details/9191351
如果上面方法不能正常安装,恭喜你中奖了,就再尝试下面方法吧

brew install gnupg
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable --ruby

or http://usabilityetc.com/articles/ruby-on-mac-os-x-with-rvm/

如果一直装不上,可能是装的过程中出现错误

把以前安装的rvm都删除掉,再重新安装
rm -rf ~/.rvm

还是不行的话,我只能说使用brew安装试试吧,我是最终是这个方法解决的

brew install ruby
pod setup

在安装pod时会很慢,巨慢无比,可以换个国内的源,换源方法:

github老添加不了
pod repo add master https://github.com/CocoaPods/Specs.git
用了国内的源
pod repo add master https://git.coding.net/hging/Specs.git
下面两个命令是不会自动更新repo的
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

安装过程中出现:

[!] The dependency `React` is not used in any concrete target.
The dependency `React/RCTText` is not used in any concrete target.

因为在新版的pod中,pod里的内容必须明确指出所用第三方库的target,否则会出现The dependency `` is not used in any concrete target这样的错误**
之前Podfile文件:

pod 'React'
pod 'React/RCTText'

改成

target "MyProject" do
pod 'React'
pod 'React/RCTText'
end

你可能感兴趣的:(react native mac 安装指南)