Setting up macOS for react native projects
To get your mac ready for react native development you should follow the instructions at https://reactnative.dev/docs/set-up-your-environment, however take note of the followings:
For ios development install Ruby and Cocoapods using brew. Use commands
which ruby
andruby -v
to verify if you are using the preinstalled version of ruby on your mac or the one installed by brew. macOS 15 comes with an old version of ruby (2.6) preinstalled at/usr/bin/ruby
. You can usebrew install cocoapods
to install latest version at/opt/homebrew/opt/ruby/bin/ruby
. Open a new terminal and verify installation viapod --version
.Open your
~/.zshrc
and make sure you have the following paths there:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=/opt/homebrew/bin:$PATH
export PATH=/opt/homebrew/opt/ruby/bin:$PATH
- https://reactnative.dev/docs/running-on-device
- https://reactnative.dev/docs/getting-started-without-a-framework
Using React Native CLI
npx @react-native-community/cli@latest init AwesomeProject
cd AwesomeProject
npm start
Then press "a" to run app on Android emulator or on an Android device if you have it connected to your mac via USB. To verify if your connected android phone is recognized run this command in temrinal:
adb devices
To build iOS apps on macOS you need Xcode, Xcode command lines, Ruby, and CocoaPods. To install Xcode (comes with iOS Simulators) go to App Store and download and install latest version of Xcode on your Mac. If you have an older macOS, you may need an older version of Xcode as listed here: https://developer.apple.com/support/xcode/ For example on macOS Big Sur you will need to download and install version 13.2 of Xcode which you can download from: https://developer.apple.com/download/all/
Then run in terminal:
npx react-native@latest init AwesomeProject
To verify that you have all requirements installed run:
npx react-native doctor
To ensure you're using the most current version of the React Native CLI run:
npx react-native@latest
To find version of installed react native:
npm view react-native version
If build fails for iOS try:
cd ios
pod update