xcode 设置调试或发布 | 反应本机 - iOS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38202209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:00:29  来源:igfitidea点击:

Set Debug or Release | React Native - iOS

iosxcodereactjsreact-native

提问by shubhsin

How to set Debug or Release mode in React Native for iOS (Xcode) like we used to do in Build Setting->LLVM Preprocessor over Native code? Is there any way or do I need to specify in JS code itself? If there is no way then how should we access the property set by Xcode in React Native JS Code?

如何像我们以前在 Build Setting->LLVM Preprocessor over Native code 中那样在 React Native for iOS (Xcode) 中设置调试或发布模式?有什么办法或者我需要在JS代码本身中指定吗?如果没有办法,那么我们应该如何访问 Xcode 在 React Native JS 代码中设置的属性?

回答by Orlando

Set debug or release mode:

设置调试或发布模式:

For iOS open your project in Xcode and select Product → Scheme → Edit Scheme... (or press ? + <). Next, select Run from the menu on the left and change the Build Configuration to Release.
For Android, by default, developer menu will be disabled in release builds done by gradle (e.g with gradle assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.

对于 iOS,在 Xcode 中打开您的项目并选择 Product → Scheme → Edit Scheme...(或按 ? + <)。接下来,从左侧菜单中选择 Run 并将 Build Configuration 更改为 Release。
对于 Android,默认情况下,在 gradle 完成的发布构建中,开发者菜单将被禁用(例如,使用 gradle assembleRelease 任务)。尽管可以通过将适当的值传递给 ReactInstanceManager#setUseDeveloperSupport 来自定义此行为。

Source: https://facebook.github.io/react-native/docs/debugging.html

来源:https: //facebook.github.io/react-native/docs/debugging.html

Access the information if you are in debug or release modewith:

如果您处于调试或发布模式,请通过以下方式访问信息

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

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

来源:如何确定我的 React Native 应用程序是基于 JavaScript 代码的调试版本还是发布版本?