ios Xcode 调试模式 - 何时开启/关闭?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12499001/
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
Xcode DEBUG Mode - when is it on/off?
提问by soleil
I have noticed that this works in dev mode (testing on the simulator, etc):
我注意到这在开发模式下有效(在模拟器上测试等):
#ifdef DEBUG
//do stuff
#endif
But when I archive and distribute test builds, the app does not act in DEBUG mode even though I'm still building with the developer profile. I would like DEBUG mode to always be the case unless I build with the deployment profile and submit to Apple.
但是当我存档和分发测试版本时,即使我仍在使用开发人员配置文件进行构建,该应用程序也不会在调试模式下运行。我希望 DEBUG 模式始终如此,除非我使用部署配置文件进行构建并提交给 Apple。
For example, when sending test builds out, I don't want to make people buy an in-app purchase, so I do something like this:
例如,当发送测试构建时,我不想让人们购买应用内购买,所以我做这样的事情:
- (BOOL)isUpgradePurchased
{
#ifdef DEBUG
return YES;
#endif
//do the real stuff to determine if purchased and return YES or NO
}
So do I also need to set a preprocessor macro DEBUG=1 for "Release"?
那么我还需要为“Release”设置一个预处理器宏 DEBUG=1 吗?
采纳答案by msk
You can also "Edit Scheme" to build Debug Configuration when archiving. See screenshot of "Edit Scheme" dialog in XCode.
您还可以在存档时“编辑方案”以构建调试配置。请参阅 XCode 中“编辑方案”对话框的屏幕截图。
回答by DrummerB
The current version of Xcode automatically sets the DEBUG
macro in new projects. It does this only for Debug build mode however.
当前版本的 Xcode 会自动DEBUG
在新项目中设置宏。但是,它仅适用于调试构建模式。
You can edit this in your projects Build Settings.
您可以在您的项目构建设置中编辑它。
I recommend you add a new, separate macro instead of editing the DEBUG one. Maybe you could add a DISTRIBUTION
or DEPLOYMENT
macro only for the release mode.
我建议您添加一个新的、单独的宏,而不是编辑 DEBUG 宏。也许你可以只为发布模式添加一个DISTRIBUTION
或DEPLOYMENT
宏。