ReactNative: development environment to build ReactNative

Build ReactNative development environment

No nonsense, the following steps:

 

First, install the required software

1Homebrew

Homebrew ,Macsystem's package manager for installingNodeJSand other necessary tools.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Annotation: In Max OS the X-10.11 ( El Capitan ) version, homebrew when you install the software may run into / usr / local directory permissions problem can not be written.

You can use the following command to fix:

sudo chown -R `whoami` /usr/local

 

2Node

Use Homebrew to install Node.js .

React Native current needs NodeJS 5.0 or later. This article published Homebrew default installation of the latest version, the general requirements are met.

brew install node

If you have installed, you can update to the latest version

brew upgrade node

If you have previously manually installed, follow the prompts, you need to brew management node and manually install a node link

brew link node

 After installing the node after the recommendations provided npm mirror to accelerate the process below). Note: Do not use CNPM ! cnpm installed modules rather strange path, Packager does not recognize normal!

npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

 

3Yarn

Yarn isFacebookalternative providednpmtools,React Nativecommand-line tools (REACT-Native-CLI), can accelerate thenodedownload module. React Nativecommand-line tool used to create, initialize, update project, run the Package Service (Packager) and other tasks.

npm install -g yarn react-native-cli

If you have installed, you can update the global reactNative to the latest version

sudo npm update -g react-native-cli

 After installing the yarn Similarly also provided after mirror source:

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

If you see EACCES: permission denied such permission error, please refer to the above homebrew Annotation, repair / usr / local ownership of the directory:

sudo chown -R `whoami` /usr/local

After installing the yarn then you can use yarn instead of npm of, for example, with yarn instead of npm install command, with the yarn add instead of a third-party library name npm install --save a third-party library name.

 

 4Watchman

Watchman is aFacebooktool to monitor the file system provided by the change. Install this tool can improve performance (when developingpackagercan quickly capture file changes in order to achieve real-time refresh). Annotation: Although this tool is recommended to install the official, but in practice, we believe that this tool must be installed, otherwise it may not develop properly.

brew install watchman

 

Second, the test results of the installation

Note: the init command created by default the latest version, but the latest 0.45 and above need to download the boost libraries compiled. This library is bulky, even in the country over the wall also difficult to download successfully, leading to a lot of people can not function properly iOS project, Chinese website provides these libraries in the forums domestic download link . If you find it troublesome, but there is no demand for the new version, you can temporarily create 0.44.3 version.

Tip: You can use the --version argument (note the two bars) to create the specified version of the project. E.g. REACT-Native the init ReactNativeDemo --version 0.44.3 . Note the version number must be accurate to two decimal places.

react-native init ReactNativeDemo  --version 0.44.3
cd ReactNativeDemo
react-native run-ios

 Note: I use the " REACT-Native RUN-ios ", the simulator can not be found, what specific reason, as a novice I do not know, has not found a solution, but unfortunately the direct use xcode runs successfully, the   steps look at the fourth part of the introduction. Error as follows:

 

 

Third, official documents

http://reactnative.cn/docs/0.49/getting-started.html#content

 

Fourth, run renderings

1, start npm services:

Elevation start

2, open Xcode, Commad + R running, you can see the download progress bar depend on flying, then relies on the library is loaded, run the project successfully

Guess you like

Origin www.cnblogs.com/XYQ-208910/p/11995714.html