Skip to content

feat(react-native): build and run on react-native-macos - #105

Open
NathanWalker wants to merge 2 commits into
mainfrom
feat/react-native-macos
Open

NathanWalker wants to merge 2 commits into
mainfrom
feat/react-native-macos

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Summary

Lets @nativescript/react-native link into react-native-macos apps (Expo Desktop, plain RN macOS). One pod serves both iOS and macOS:

 NativeScriptNativeApi.podspec
-  platforms   ios 13.0
+  platforms   ios 13.0, osx 14.0
+  osx.exclude NativeScriptUIView* + Fabric/   # UIKit host views; no AppKit host yet
-  resources   metadata/*.nsmd
+  ios.resources  metadata/metadata.ios*.nsmd
+  osx.resources  metadata/metadata.macos*.nsmd

 build_react_native_turbomodule.sh
   metagen ios
+  metagen macos                  # before ios-sim, so the staged Gsd .inc stays ios-sim
   metagen ios-sim
-  GeneratedSignatureDispatch.inc
+  GeneratedSignatureDispatch.{ios,macos}.inc + a TARGET_OS_OSX switch
   Libffi.xcframework  ios, ios-sim
+                      macos (macosx-universal)

 NativeScriptNativeApiModule.mm
+  bundledMetadataPath: metadata.macos.{arm64,x86_64} under TARGET_OS_OSX
+  NSImage instead of UIImage for the image loader; setTemplate: for template images
+  NativeScriptRefreshUIKitHostView stub on macOS

On this branch init() installs into Worklets on every platform, so the JS side needs no change. fix/react-native-reported-issues adds supportsWorkletRuntime() (iOS only); when that lands it should also return true for Platform.OS === "macos".

The first commit is the change from #104 (macOS metadata targets the SDK version, not macos11.0). Without it the macOS metadata lacks SCStream, SCScreenshotManager, NSGlassEffectView and everything newer than macOS 11. It drops out of this PR once #104 is merged and merged into this base.

Evidence

Built and run in an Expo Desktop app (expo-desktop-template-blank-typescript@55.83.10: Expo SDK 55, react-native-macos 0.83.0, Hermes 0.14.1, New Architecture, react-native-worklets 0.8.3).

  • Before: pod install refuses the pod for a macOS target (platform :ios only).
  • After: the app builds, and from JS:
NativeScript.init()                       -> true
NativeScript.getRuntimeBackend()          -> "hermes-jsi"
runOnUI(() => { "worklet"; ... })         -> { mainThread: true,
                                               title: "Expo NS Desktop",
                                               macos: "Version 26.6.2 (Build 25G83)" }
runOnUI: window.title = "..."             -> NSWindow title changes on screen
typeof NSGlassEffectView                  -> "function"
SCScreenshotManager capture of own window -> 2560x1440 PNG, no Screen Recording prompt

Tested on top of fix/react-native-reported-issues and then cherry-picked here; the only conflict was the index.ts gate above. Not yet run: the iOS TurboModule test (npm run test-rn-turbomodule) against the changed podspec. iOS paths are unchanged in source, so that run is what this draft is waiting on.

Build note: on a Mac whose libclang is arm64-only, the x86_64 metadata generator doesn't link; copy the arm64 generator into metadata-generator/dist/x86_64 and write dist/.source_hash (the hash covers absolute paths, so it's per checkout).

Merge Danger

Door: two-way

Blast Radius: packaging

The tarball grows by the two macOS .nsmd files (~6.5 MB each), the macOS signature-dispatch table (~8.5 MB source) and a macOS libffi slice. iOS consumers get the same sources and resources as before, selected through s.ios.*.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb9dd81d-30a7-47c2-b993-fee3a3a64024

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

macOS metadata was generated for macos11.0, and the generator leaves out
declarations introduced after the target, so everything newer than macOS 11
was missing from the embedded metadata: ScreenCaptureKit's SCStream (12.3),
SCScreenshotManager (14.0), NSGlassEffectView (26.0) and the rest. iOS already
targets the SDK version.
The TurboModule pod now declares macOS 14 alongside iOS 13, so Expo Desktop
and other react-native-macos apps can link it. On macOS:

- metadata.macos.{arm64,x86_64}.nsmd is bundled and selected at runtime
- Libffi.xcframework carries a macOS slice
- the Hermes signature dispatch table is chosen per platform at compile time
- NativeScriptUIView (UIKit host views) is left out until an AppKit host exists

Verified in an Expo Desktop (SDK 55, react-native-macos 0.83) app: init(),
runOnUI worklets reading and writing NSApplication/NSWindow on the main thread,
and ScreenCaptureKit captures of the app's own window.
@NathanWalker
NathanWalker force-pushed the feat/react-native-macos branch from ce8f3a9 to 64dc06c Compare November 20, 2026 21:24
@NathanWalker
NathanWalker changed the base branch from android-react-native to main November 20, 2026 21:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant