React Native for macOS is a really powerful implementation of React Native for building Mac apps, but the RN macos documentation (as of today) is straight up wrong and won't work.
Here's how to spin one up!
This assumes you are on a Mac and have installed all the prerequisites for RN iOS.
Your React Native for macOS app will live inside a normal React Native app, as a macos folder alongside your ios and android folders.
npx @react-native-community/cli@latest init PizzaApp --version 0.78.3Answer "No" to the Cocoapods question, as we won't be using the iOS or Android apps for this demo.
cd PizzaApp
npx react-native-macos-initIn ./macos/Podfile, make the following changes:
use_react_native!(
:path => '../node_modules/react-native-macos',
- :hermes_enabled => false,
+ :hermes_enabled => true,
:fabric_enabled => ENV['RCT_NEW_ARCH_ENABLED'] == '1',
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)Warning
You'll need to pass in RCT_NEW_ARCH_ENABLED=1 for pod install and for building/running the app or it WILL NOT WORK.
You cannot just update :fabric_enabled above to true.
RCT_NEW_ARCH_ENABLED=1 pod install --project-directory=macosnpm run startYou should see the Metro packager pop up.
In a new terminal tab or window, run this in the project directory:
RCT_NEW_ARCH_ENABLED=1 npx react-native run-macosYou should see this pop up!
Go to App.tsx and start your journey!
