Setting up React Native for a MacOS device is quite straightforward, let's get started.
Install Xcode from the App Store
Firstly, install Xcode from the Apple App Store and setup iOS simulator.
Install Xcode Command Line Tools
Once you have Xcode, you need to install Xcode Command Line Tools. Run the following command in your terminal.
xcode-select --install
Install Java/OpenJDK
Next, you will need to download and install Java/OpenJDK. Ensure that you allow the permission required for the installation.
You might also want jenv which is a command line to easily switch different Java versions.
brew install jenv
Then export the path and configurations.
# Shell: bash
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
# Shell: zsh
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(jenv init -)"' >> ~/.zshrc
To link and set the Java version, run the following command (depending on your java version, update the respective version number).
jenv add /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
jenv versions
jenv global temurin64-11.0.18
jenv local temurin64-11.0.18
jenv shell temurin64-11.0.18
Install NVM (LST recommended)
It's recommended to use Node LTS. If you don't have it installed, make sure to use NVM to easily install and switch between different node versions.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
nvm install 16
nvm alias default v16.19.0
nvm use default
Install Watchman
You also need to install watchman which is a watcher to automatically detect, build and push the update to device during development.
brew install watchman
Install Ruby
macOS comes with the old version of ruby but we recommend a newer updated version (v 2.7.7)
brew install rbenv ruby-build
rbenv init
rbenv install 2.7.7
rbenv local 2.7.7 && rbenv global 2.7.7
Install Cocoapods
Cocoapods is also required to build iOS projects and you have 2 options to install it, using Ruby gem and Homebrew. The recommended version of Cocoapods is 1.11.2 which is the stable version we have tested.
gem install cocoapods -v 1.11.2
You may also use Homebrew to install cocoapods if you don't prefer to use ruby gem.
brew install cocoapods
Create New Expo/React Native Project
You may refer to Setting up new Expo project with HestiaKit component to get started and speed up your mobile development. Happy coding!