Install Homebrew:
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
Install Node.js and npm:
brew install node
Install Watchman:
brew install watchman
Install CocoaPods:
sudo gem install cocoapods
Install Xcode:
Download and install Xcode from the App Store.
Open Xcode and agree to the license agreements:
sudo xcodebuild -license
Set Xcode Command Line Tools:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Install Android Studio:
Set Up Android Environment Variables:
Add the following lines to your ~/.zshrc
(or ~/.bash_profile
or ~/.profile
):
export ANDROID_HOME=$HOME/Library/Android/sdk
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
Reload your shell configuration:
source ~/.zshrc
Initialize a New React Native Project:
npx react-native init <project_name>
Add macOS Support:
npx react-native init <project_name> --template react-native-template-macos
Error: cli.init is not a function
Solution: Uninstall the globally installed react-native-cli
:
npm uninstall -g react-native-cli
Re-run the project initialization:
npx react-native init <project_name>
Error: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory is a command line tools instance
Solution: Set the correct Xcode path:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Error: CocoaPods could not find compatible versions for pod "React-RuntimeHermes"
Solution: Increase the iOS deployment target in your Podfile
:
platform :ios, '15.0'
Error: adb: command not found
Solution: Install Android Platform Tools to get the adb
command:
brew install --cask android-platform-tools
Error: Failed to launch emulator. Reason: No emulators found
Tools
> AVD Manager
.Error: SDK location not found
Solution: Set the ANDROID_HOME
environment variable and configure the SDK location:
echo "sdk.dir=$HOME/Library/Android/sdk" > android/local.properties
react_native_project_provisioning.py