01、Mac 上配置RN的開發環境

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中修改代碼

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容