Before we start installing react native we need to setup
- JDK
- Node
- Watchman
- Android SDK
- iOS SDK
- Cocoapod
Here we will go through the installation of its dependency.
brew cask install java
brew cask info java
Normally $PATH path variable are can be placed in ~/.bash_profile or ~/.bashrc or ~/.zshrc depending on the type of terminal tool used. So it better to put following command in all of terminal profile file.
- .bash_profile :- bash_profile is executed for login shells
- .bashrc :- .bashrc is executed for interactive non-login shells.
- .zshrc:- is executed for zsh type of shell.
To find type of shell you are using
echo $SHELL
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME
Then make the change permanent
$ source ~/.bash_profile
You can download Android Studio and then install Android SDK, Android NDK, gradle from there or we can use brew for this
brew install ant
brew install maven
brew install gradle
brew install android-sdk
brew install android-ndk
Open ~/.bash_profile or ~/.bashrc or ~/.zshrc and write following code
export ANT_HOME=/usr/local/opt/ant
export MAVEN_HOME=/usr/local/opt/maven
export GRADLE_HOME=/usr/local/opt/gradle
export ANDROID_HOME=/usr/local/opt/android-sdk
export ANDROID_NDK_HOME=/usr/local/opt/android-ndk
export PATH=$ANT_HOME/bin:$PATH
export PATH=$MAVEN_HOME/bin:$PATH
export PATH=$GRADLE_HOME/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Then make the change permanent
$ source ~/.bash_profile
$ sudo gem install cocoapods
$ brew install node
$ brew install watchman
It is recommended to use yarn over npm by facebook. We can install react native cli via
$ npm install -g yarn
$ yarn global add react-native-cli
Now to create react native project
react-native init ProjectName
or we can use npx directly to create react native project
$ npx react-native init AwesomeProject
react-native doctor, a new command to help you out with getting started, troubleshooting and automatically fixing errors with your development environment.
$ npx @react-native-community/cli doctor
$ cd ProjectName
$ npx react-native start
$ npx react-native run-ios
$ npx react-native run-android
$ brew cask install react-native-debugger
=======
JDK 14 does not support gradle version less than 6.3. So it is required to use gradle version greater than 6.3. For this
cd android
- In
gradle-wrapper.properties
please use grade version 6.3 or above.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
This require to change permission to gradlew
$ cd android
$ chmod +x gradlew