ReactNative 環境配置
一直是從事iOS的開發,現在研究下mac環境下reatNative的環境配置:
1. 安裝HomeBlew(OS系統上的一個安裝包管理器,安裝後可以方便後續安裝包的安裝。)
終端命令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. 安裝Node.js (服務端的JavaScript運行環境)
下載地址:https://nodejs.org/download/
成功安裝後,終端會有如下提示信息:
Node.js was installed at: /usr/local/bin/node
npm was installed at: /usr/local/bin/npm
Make sure that /usr/local/bin is in your $PATH.
3. 建議安裝WatchMan(React修改source文件的一個工具)
終端命令:
brew install watchman
4. 安裝Flow: 一個JavaScript 的靜態類型檢查器。
終端命令:
brew install flow
5. 安裝React Native CLI: 用來開發React Native的命令行工具
終端命令:
npm install -g react-native
創建項目1. 新建一個項目
新建一個“HelloWorld”的項目,每個語言的開始教程都是這個,我們也不例外。
操作超級簡單,只需終端輸入命令行:
react-native init HelloWorld
這樣就新建了一個工程,前往文件夾:/用戶/xxx/HelloWorld (xxx為電腦用戶名),打開iOS文件下的工程:
註意:打開後會報以下錯誤
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/strtod.cc‘? Compiling fast-dtoa.cc
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/fast-dtoa.cc‘? Compiling fixed-dtoa.cc
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/fixed-dtoa.cc‘? Compilingdouble-conversion.cc
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/double-conversion.cc‘? Compiling diy-fp.cc
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/diy-fp.cc‘? Compiling cached-powers.cc
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/cached-powers.cc‘? Compiling bignum.cc
? error: Build input file cannot be found:‘/Users/rod/dev/react/testing/awesome/node_modules/react-native/third-party/double-conversion-1.1.6/src/bignum.cc‘
解決方案
cd node_modules/react-native/scripts && ./ios-install-third-party.sh &&cd../../../
cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh
ReactNative 環境配置