【发布时间】:2023-01-03 19:03:05
【问题描述】:
我正在使用 react-native@0.66.1,
我想使用 chrome 控制台而不是 flipper 进行调试。
在 ios 模拟器开发者菜单中,我随机得到
Open Debugger(-> 打开脚蹼)或Debug JS Remotely(-> 打开 chrome)
我可以永久禁用 flipper 并只使用 chrome 进行调试吗?
谢谢
【问题讨论】:
标签: react-native
我正在使用 react-native@0.66.1,
我想使用 chrome 控制台而不是 flipper 进行调试。
在 ios 模拟器开发者菜单中,我随机得到
Open Debugger(-> 打开脚蹼)或Debug JS Remotely(-> 打开 chrome)
我可以永久禁用 flipper 并只使用 chrome 进行调试吗?
谢谢
【问题讨论】:
标签: react-native
找到了一个方法: 在 node_modules/react-native/React/CoreModules/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
【讨论】: