如何在 React Native 中的第一个 运行 开始远程调试

How start remote debug on the very first run in react native

如何在 React Native 中的第一个应用 运行 上启动远程调试?

我使用开发者菜单启动 Debug JS Remotely 并重新加载应用程序,因此无法调试仅在第一个 运行 出现的代码。

您需要用本机代码对其进行硬编码。

对于 android 我相信是这个:

https://github.com/facebook/react-native/blob/786c1ecc2a6856967d676da68eb02f89eb38fb79/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java#L88

我终于在这个article中找到了解决方案。

可以在 iOS

上以编程方式启动 Debug JS Remotely
import { NativeModules } from 'react-native';

if (__DEV__) {
 NativeModules.DevSettings.setIsDebuggingRemotely(true)
}

react-native-devsettings-android 运行 android

上的此代码需要库