1阅畴、打開(kāi)本地權(quán)限
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迅耘、檢測(cè)brew是否安裝成功
brew
4贱枣、更新brew
brew update
5、如果4失敗颤专,再次執(zhí)行步驟1纽哥,
Brew update
會(huì)出現(xiàn)如下:
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春塌、設(shè)置npm鏡像加速后續(xù)進(jìn)程
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
設(shè)置鏡像源:
yarn configsetregistry https://registry.npm.taobao.org--global
yarn configsetdisturl https://npm.taobao.org/dist—global
安裝完yarn之后就可以用yarn代替npm了摔笤,例如用yarn代替npm install命令够滑,用yarn add某第三方庫(kù)名代替npm install --save某第三方庫(kù)名。
10吕世、測(cè)試安裝
10.1創(chuàng)建工程
react-nativeinit AwesomeProject
10.2導(dǎo)出成功包
cd AwesomeProject
react-nativerun-ios
11彰触、xcode上運(yùn)行工程時(shí),要先打開(kāi)服務(wù)器權(quán)限
npm start
12命辖、在index.ios.js中修改代碼