Setting Up a Mac Machine for React Native Development
React Native is a popular framework for building mobile apps using JavaScript and React. To get started with React Native development on your Mac machine, follow these steps:
Setup iOS Environment
- Install Xcode: You can install Xcode from the App Store. If you need a specific version, refer to this stack overflow link.
- Open Xcode and install any required tools.
- Install Homebrew (which also installs Command Line Tools):
Then set the path:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
To check if the path is set correctly:(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile eval "$(/usr/local/bin/brew shellenv)"vi ~/.zprofile - Install Node using Homebrew:
brew install node - Install Watchman using Homebrew:
brew install watchman - Install Cocoapods using Homebrew:
brew install cocoapods - Create a new React Native project:
npx react-native@latest init ReactNativeDemo - Go to the project directory:
cd ReactNativeDemo - Install pods (if not already done during project initialization):
cd ios && pod install && cd .. - Run the project on iOS:
npx react-native run-ios
Setup Android Environment
- Download Android Studio from developer.android.com.
- Install Android Studio and all required components.
- Set the path for Android SDK by running the following commands:
To check if the path is set correctly:export ANDROID_HOME=/Users/<your username>/Library/Android/sdk export ANDROID_SDK_ROOT=$ANDROID_HOME export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
It should look like:vi ~/.bash_profile
If not, manually update the file and save it by pressing 'ESC' and then typing ':wq'. To apply changes immediately without closing the terminal:ANDROID_HOME=/Users/<your username>/Library/Android/sdk ANDROID_SDK_ROOT=$ANDROID_HOME PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
You can also check the path by running:source ~/.bash_profileecho $PATH - Install Java by running the following commands:
Get the path where the cask was installed to double-click the installer.brew tap homebrew/cask-versions brew install --cask zulu11brew info --cask zulu11 - Set the path for JDK. After installing the JDK, update your JAVA_HOME environment variable. If you used the above steps, the JDK will likely be at:
To check if the path is set correctly:/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
It should look like:vi ~/.bash_profile
If not, manually update the file and save it by pressing 'ESC' and then typing ':wq'. To apply changes immediately without closing the terminal:ANDROID_HOME=/Users/<your username>/Library/Android/sdk ANDROID_SDK_ROOT=$ANDROID_HOME JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$JAVA_HOME
You can also check the path by running:source ~/.bash_profileecho $PATH - Install Homebrew (skip if already installed):
Then set the path:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
To check if the path is set correctly:(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile eval "$(/usr/local/bin/brew shellenv)"vi ~/.zprofile
Comments
Post a Comment