Setting up the development environment

Install Homebrew

Homebrew, the package manager for Mac, is used to install NodeJS and other necessary tools.

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

You can also choose domestic resources

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

Install the Node

brew install node
Copy the code

If it gets stuck, cancel the operation and reinstall it, which will often get stuck

Install the Yarn and React Native command line tools

Yarn is a tool provided by Facebook to replace NPM and speed up the download of Node modules. React Native’s command-line tools perform tasks such as creating, initializing, updating projects, and running the Packager service.

npm install -g yarn react-native-cli
Copy the code

Install the Watchman

Watchman is a tool provided by Facebook to monitor file system changes. Installing this tool can improve development-time performance (Packager can quickly catch changes to files for real-time refreshes).

brew install watchman
Copy the code

Install the Flow

Flow is a static JS type checking tool. The odd colon question mark you see in many of the examples, and type-like writing of method parameters, are part of the flow tool’s syntax. This syntax is not part of the ES standard, but Facebook’s own code specification. So beginners can skip it (you don’t need to install the tool, and it’s not recommended to try to learn flow syntax).

brew install flow
Copy the code

(Yarn,Watchman, and Flow can not be installed)

Install cococapods:

sudo gem install cocoapods
Copy the code

Legacy projects integrate with RN

Cocoapods

Add the following code to your Podfile

rn_path = '.. /node_modules/react-native' pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec" pod 'React', path: rn_path, subspecs: [ 'Core', 'RCTActionSheet', 'RCTAnimation', 'RCTGeolocation', 'RCTImage', 'RCTLinkingIOS', 'RCTNetwork', 'RCTSettings', 'RCTText', 'RCTVibration', 'RCTWebSocket', 'BatchedBridge' ]Copy the code