1、打开本地权限
sudo chown -R `whoami` /usr/local
2、安装honebrew
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local —strip1
3、检测brew是否安装成功
brew
4、更新brew
brew update
5、如果4失败,再次执行步骤1,
Brew update
会出现如下:
Receiving objects: 100% (1130/1130), 1.21 MiB | 228.00 KiB/s, done.
Resolving deltas: 100% (117/117), done.
From https://github.com/Homebrew/brew
* [new branch]master-> origin/master
HEAD is now at 56458f0 Merge pull request #3277 from sjackman/audit-notable
To restore the stashed changes to /usr/local run:
'cd /usr/local && git stash pop'
==> Downloading https://homebrew.bintray.com/bottles-portable/portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz
curl: (7) Failed to connect to akamai.bintray.com port 443: Operation timed out
Error: Download failed: https://homebrew.bintray.com/bottles-portable/portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz
Error: Failed to install vendor Ruby.
6、安装folw, watchman
brew install flow
brew install watchman
7、Node.js直接下载双击安装
8、设置npm镜像加速后续进程
npmconfig set registry https://registry.npm.taobao.org --global
npmconfig set disturl https://npm.taobao.org/dist —global
9、安装Yarn、React Native的命令行工具(react-native-cli)
npminstall -g yarn react-native-cli
设置镜像源:
yarn configsetregistry https://registry.npm.taobao.org--global
yarn configsetdisturl https://npm.taobao.org/dist—global
安装完yarn之后就可以用yarn代替npm了,例如用yarn代替npm install命令,用yarn add某第三方库名代替npm install --save某第三方库名。
10、测试安装
10.1创建工程
react-nativeinit AwesomeProject
10.2导出成功包
cd AwesomeProject
react-nativerun-ios
11、xcode上运行工程时,要先打开服务器权限
npm start
12、在index.ios.js中修改代码