Mac OS
Setting up your MacBook (Apple Silicon) for React Native development requires careful configuration of the CLI tools, Xcode, and Rosetta to avoid common errors during yarn install or project builds. Here’s a step-by-step guide:
1. Install Xcode & Command Line Tools (Silicon-Optimized)
-
Install Xcode from the Mac App Store.
-
Open Xcode, agree to licenses, and install Command Line Tools:
xcode-select --install -
Verify installation:
xcode-select -p
# Should return: /Applications/Xcode.app/Contents/Developer
2. Configure Rosetta for Terminal (If Needed)
Apple Silicon Macs can run Intel-based tools via Rosetta 2. Some React Native dependencies (e.g., older pods) may need it.
-
For Terminal (and your shell):
- Right-click Terminal.app → Get Info → Check "Open using Rosetta".
- Restart Terminal.
-
For specific tools (e.g.,
yarn), run:arch -x86_64 yarn install
3. Install Homebrew (Apple Silicon + Rosetta)
-
Native (ARM64) Homebrew (recommended for most tools):
/bin/bash -c "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Add to your shell config (e.g.,
~/.zshrc):eval "\$(/opt/homebrew/bin/brew shellenv)" -
Intel (Rosetta) Homebrew (for incompatible tools):
arch -x86_64 /bin/bash -c "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Prefix commands with
arch -x86_64when needed.
4. Install Node.js & Yarn
-
Use nvm (Node Version Manager) to manage Node.js versions:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bashInstall Node.js (LTS recommended):
nvm install 18
nvm use 18 -
Install Yarn:
npm install -g yarn
5. React Native CLI Setup
-
Install the React Native CLI:
npm install -g react-native-cli -
Initialize a project (if needed):
npx react-native init MyProject
6. Fix Rosetta Emulator Errors in yarn install
If you see errors like:
error: incompatible architecture (have 'x86_64', need 'arm64')
-
Solution 1: Run
yarn installnatively (without Rosetta):unset PREFIX && yarn install -
Solution 2: Force Rosetta for all dependencies:
arch -x86_64 yarn install -
Solution 3: Rebuild packages for ARM64:
rm -rf node_modules && yarn install --force
7. CocoaPods Setup (for iOS)
-
Install CocoaPods (Ruby must be ARM64-native):
sudo gem install cocoapods -
Navigate to
ios/and install pods:arch -arm64 pod install --repo-update
8. Run Your React Native Project
-
iOS (requires Xcode):
npx react-native run-ios -
Android: Set up JDK and Android Studio separately.
Troubleshooting
-
Error: "Folly" or other build failures:
Deleteios/Pods,ios/build, and reinstall:cd ios && arch -arm64 pod deintegrate && pod install -
Xcode "No such module":
Clean build folder (Product → Clean Build Folder in Xcode).
Final Notes
- Prefer ARM64-native tools where possible (e.g., Node.js, Ruby, Homebrew).
- Use Rosetta only for stubborn Intel-only dependencies.
- Keep Xcode and CLI tools updated.
Let me know if you hit a specific error! 🚀
You are running pod install under Rosetta2 emulation, which is not recommended for Apple Silicon (M1/M2/M3) Macs. This can cause slow performance and architecture issues.
To fix this, you should run CocoaPods natively for arm64. Here’s what to do:
- Open a new Terminal window (not under Rosetta).
- Run the following command to execute a shell as arm64 and install pods:
env /usr/bin/arch -arm64 /bin/bash --login -c "cd ios && pod install"
This will ensure CocoaPods runs natively and avoids architecture problems. Let me know if you want me to run this command for you.
Homebrew
useful packages
- ImageOptim: This is a tool that optimizes images for the web. It can help to reduce the size of your images without sacrificing quality. You can install it using the following command:
brew install imageoptim
- webpconv: This is a tool that converts images to the WebP format. WebP is a newer image format that can provide better compression than JPEG or PNG. You can install it using the following command:
brew install webpconv
- jq: This is a command-line JSON processor that allows you to easily work with JSON data. It is a great tool for debugging APIs and working with JSON files. You can install it using the following command:
brew install jq
These are just a few of the many interesting Homebrew packages that are available for front-end developers. With Homebrew, you can easily install and manage all of the tools you need to build modern web applications.
Raycast
brew install --cask raycast
Oh-My-Posh
https://ohmyposh.dev/docs/installation/macos
brew install jandedobbeleer/oh-my-posh/oh-my-posh