3434#import < react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
3535#import < react/runtime/JSRuntimeFactory.h>
3636
37- #if TARGET_OS_OSX && __has_include("RCTDevMenu.h") // [macOS
38- #import < React/RCTSurfaceHostingView+Private.h>
39- #import < react/utils/ManagedObjectWrapper.h>
37+ #if RCT_DEV_MENU // [macOS
4038#import " RCTDevMenu.h"
4139#endif // macOS]
4240
@@ -159,14 +157,12 @@ - (RCTPlatformView *)viewWithModuleName:(NSString *)moduleName // [macOS]
159157 surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor ];
160158#endif // [macOS]
161159
162- #if TARGET_OS_OSX && __has_include("RCTDevMenu.h") && RCT_DEV
160+ #if RCT_DEV_MENU // [macOS
163161 RCTDevMenu *devMenu = [self .reactHost.moduleRegistry moduleForClass: [RCTDevMenu class ]];
164162 if (devMenu) {
165- _contextContainer->erase (" RCTDevMenu" );
166- _contextContainer->insert (" RCTDevMenu" , facebook::react::wrapManagedObject (devMenu));
163+ surfaceHostingProxyRootView.devMenu = devMenu;
167164 }
168- [surfaceHostingProxyRootView setContextContainer: _contextContainer]; // [macOS]
169- #endif
165+ #endif // macOS]
170166
171167 if (_configuration.customizeRootView != nil ) {
172168 _configuration.customizeRootView (surfaceHostingProxyRootView);
@@ -200,15 +196,19 @@ - (RCTPlatformView *)createRootViewWithBridge:(RCTBridge *)bridge
200196{
201197 BOOL enableFabric = _configuration.fabricEnabled ;
202198 RCTPlatformView *rootView = RCTAppSetupDefaultRootView (bridge, moduleName, initProps, enableFabric); // [macOS]
203- #if !TARGET_OS_OSX // [macOS]
204- rootView.backgroundColor = [UIColor systemBackgroundColor ];
205- #endif // [macOS]
206199
207- #if TARGET_OS_OSX // [macOS
200+ #if RCT_DEV_MENU // [macOS
208201 if (enableFabric && [rootView isKindOfClass: [RCTSurfaceHostingView class ]]) {
209- [(RCTSurfaceHostingView *)rootView setContextContainer: _contextContainer];
202+ RCTDevMenu *devMenu = [bridge moduleForClass: [RCTDevMenu class ]];
203+ if (devMenu) {
204+ [(RCTSurfaceHostingView *)rootView setDevMenu: devMenu];
205+ }
210206 }
211207#endif // macOS]
208+
209+ #if !TARGET_OS_OSX // [macOS]
210+ rootView.backgroundColor = [UIColor systemBackgroundColor ];
211+ #endif // [macOS]
212212
213213 return rootView;
214214}
@@ -227,15 +227,6 @@ - (RCTPlatformView *)createRootViewWithBridge:(RCTBridge *)bridge
227227 _contextContainer->erase (" RuntimeScheduler" );
228228 _contextContainer->insert (" RuntimeScheduler" , _runtimeScheduler);
229229
230- #if TARGET_OS_OSX && __has_include("RCTDevMenu.h") && RCT_DEV
231- // Insert dev menu for macOS context menu access using proper moduleForClass pattern
232- RCTDevMenu *devMenu = [bridge moduleForClass: [RCTDevMenu class ]];
233- if (devMenu) {
234- _contextContainer->erase (" RCTDevMenu" );
235- _contextContainer->insert (" RCTDevMenu" , facebook::react::wrapManagedObject (devMenu));
236- }
237- #endif
238-
239230 return RCTAppSetupDefaultJsExecutorFactory (bridge, turboModuleManager, _runtimeScheduler);
240231 } else {
241232 return RCTAppSetupJsExecutorFactoryForOldArch (bridge, _runtimeScheduler);
0 commit comments