在Chrome而不是Flipper中调试React-native

k5hmc34c  于 2023-01-05  发布在  React
关注(0)|答案(1)|浏览(511)

我用的是React原@0.66.1
我想调试使用chrome控制台,而不是flipper。
在ios模拟器开发者菜单中,我随机得到Open Debugger(-〉打开flipper)或Debug JS Remotely(-〉打开chrome)
我可以永久禁用flipper并且只使用chrome进行调试吗?
谢啦,谢啦

gmol1639

gmol16391#

找到了办法:在node_modules/React Native/React/核心模块/RCTDevMenu. mm中禁用此模块

diff --git a/node_modules/react-native/React/CoreModules/RCTDevMenu.mm b/node_modules/react-native/React/CoreModules/RCTDevMenu.mm
index 881c3f2..1447e8f 100644
--- a/node_modules/react-native/React/CoreModules/RCTDevMenu.mm
+++ b/node_modules/react-native/React/CoreModules/RCTDevMenu.mm
@@ -230,36 +230,7 @@ RCT_EXPORT_MODULE()
                                                }]];
 
   if (!devSettings.isProfilingEnabled) {
-#if RCT_ENABLE_INSPECTOR
-    if (devSettings.isDeviceDebuggingAvailable) {
-      // For on-device debugging we link out to Flipper.
-      // Since we're assuming Flipper is available, also include the DevTools.
-      // Note: For parity with the Android code.
-      [items addObject:[RCTDevMenuItem
-                           buttonItemWithTitleBlock:^NSString * {
-                             return @"Open Debugger";
-                           }
-                           handler:^{
-                             [RCTInspectorDevServerHelper
-                                          openURL:@"flipper://null/Hermesdebuggerrn?device=React%20Native"
-                                    withBundleURL:bundleManager.bundleURL
-                                 withErrorMessage:@"Failed to open Flipper. Please check that Metro is runnning."];
-                           }]];
-
-      [items addObject:[RCTDevMenuItem
-                           buttonItemWithTitleBlock:^NSString * {
-                             return @"Open React DevTools";
-                           }
-                           handler:^{
-                             [RCTInspectorDevServerHelper
-                                          openURL:@"flipper://null/React?device=React%20Native"
-                                    withBundleURL:bundleManager.bundleURL
-                                 withErrorMessage:@"Failed to open Flipper. Please check that Metro is runnning."];
-                           }]];
-    } else if (devSettings.isRemoteDebuggingAvailable) {
-#else
     if (devSettings.isRemoteDebuggingAvailable) {
-#endif
       // For remote debugging, we open up Chrome running the app in a web worker.
       // Note that this requires async communication, which will not work for Turbo Modules.
       [items addObject:[RCTDevMenuItem

相关问题