Skip to main content

Setup Mac Machine for React Native development

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

  1. Install Xcode: You can install Xcode from the App Store. If you need a specific version, refer to this stack overflow link.
  2. Open Xcode and install any required tools.
  3. Install Homebrew (which also installs Command Line Tools):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    Then set the path:
    (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile
    eval "$(/usr/local/bin/brew shellenv)"
    To check if the path is set correctly:
    vi ~/.zprofile
  4. Install Node using Homebrew:
    brew install node
  5. Install Watchman using Homebrew:
    brew install watchman
  6. Install Cocoapods using Homebrew:
    brew install cocoapods
  7. Create a new React Native project:
    npx react-native@latest init ReactNativeDemo
  8. Go to the project directory:
    cd ReactNativeDemo
  9. Install pods (if not already done during project initialization):
    cd ios && pod install && cd ..
  10. Run the project on iOS:
    npx react-native run-ios

Setup Android Environment

  1. Download Android Studio from developer.android.com.
  2. Install Android Studio and all required components.
  3. Set the path for Android SDK by running the following commands:
    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
    To check if the path is set correctly:
    vi ~/.bash_profile
    It should look like:
    ANDROID_HOME=/Users/<your username>/Library/Android/sdk
    ANDROID_SDK_ROOT=$ANDROID_HOME
    PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
    If not, manually update the file and save it by pressing 'ESC' and then typing ':wq'. To apply changes immediately without closing the terminal:
    source ~/.bash_profile
    You can also check the path by running:
    echo $PATH
  4. Install Java by running the following commands:
    brew tap homebrew/cask-versions
    brew install --cask zulu11
    Get the path where the cask was installed to double-click the installer.
    brew info --cask zulu11
  5. 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:
    /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
    To check if the path is set correctly:
    vi ~/.bash_profile
    It should look like:
    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
    If not, manually update the file and save it by pressing 'ESC' and then typing ':wq'. To apply changes immediately without closing the terminal:
    source ~/.bash_profile
    You can also check the path by running:
    echo $PATH
  6. Install Homebrew (skip if already installed):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    Then set the path:
    (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile
    eval "$(/usr/local/bin/brew shellenv)"
    To check if the path is set correctly:
    vi ~/.zprofile

Comments

Popular posts from this blog

ERROR FIX(React Native): Installing Ruby Gems, error Your Ruby version is 2.6.8 but your Gemfile specified >= 2.6.10

Fixing React Native iOS Build Errors If you're encountering the following errors while building your React Native project: ERROR FIX: Installing Ruby Gems, error Your Ruby version is 2.6.8 but your Gemfile specified >= 2.6.10, error Looks like your 10S environment is not properly set. Please go to React Native Environment Setup and follow the React Native CLI QuickStart guide for macOS and iOS. This issue is occurring due to a Ruby version mismatch. To resolve it, follow these steps: Step 1: Install rbenv using Homebrew brew install rbenv ruby-build If Homebrew is not installed, you can install it from the Homebrew website . Use the following commands to install Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile eval "$(/usr/local/bin...