Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine if my React Native app is a debug or release build from JavaScript code?

I'd like to add some debug-only UI to my React Native app, but I can't find any equivalent of RCT_DEBUG or RCT_DEV compile-time flags in the JavaScript environment. Is there one?

Use case: I want to add a status bar that shows the number of HTTP requests initiated by my app. Obviously this is not part of a shipping app, but it would help me check my work while in development and testing.

like image 821
escouten Avatar asked Dec 28 '15 18:12

escouten


People also ask

How do you check if APK is debug or release programmatically?

There are different way to check if the application is build using debug or release certificate, but the following way seems best to me. According to the info in Android documentation Signing Your Application, debug key contain following subject distinguished name: "CN=Android Debug,O=Android,C=US".

How do I debug an app in React Native?

You can also use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on Mac OS and Ctrl+M on Windows and Linux. Alternatively for Android, you can run the command adb shell input keyevent 82 to open the dev menu (82 being the Menu key code).


1 Answers

if (__DEV__) {     console.log('I am in debug'); } 

You can see this approach is being used in React Native repository.

like image 68
rmevans9 Avatar answered Sep 30 '22 14:09

rmevans9