如何在iOS中使用发布模式来调试问题? [英] How do you debug an issue with a release mode build in iOS?

查看:78
本文介绍了如何在iOS中使用发布模式来调试问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS应用程序,但我注意到只有在发布模式下构建该应用程序时才能再现的错误.我发现运行已构建的发布模式应用程序的唯一方法是构建存档,使用调试配置文件对其进行签名,然后对设备进行临时部署.但是,使用这种方法时,我无法附加调试器,而且我甚至不确定是否可以附加它,如果发行版本在代码上运行了优化器后,它是否可以正常工作.

I am working on an iOS app and I have noticed a bug that is only reproducible when the app is built in release mode. The only way I have found to run a release mode app that I have built is by building an archive, signing it with my debug profile, and doing an ad-hoc deployment to my device. Using this method however I can't attach with a debugger, and I'm not even sure if I could attach it if it would work well after the release build had run the optimizer on the code.

有人知道一种调试仅在发布模式下构建应用程序时才可重现的问题的好方法吗?

Does anyone know of a good way to debug an issue that is only reproducible when an app is build in release mode?

推荐答案

通常,调试版本禁用优化(-O0)以使调试更加容易,而Release版本则启用优化(-O3-Os),使代码运行更快,但也使调试更加困难(但并非不可能).您可以进入Debug配置中的Xcode中的构建设置,并暂时提高优化级别-这将保留所有其他调试功能(符号等),但也希望能消除Release模式的错误. (完成操作后,别忘了在Debug配置中将优化级别重置为-O0!)

Normally Debug builds have optimisation disabled (-O0) to make debugging easier, whereas Release builds have optimisation enabled (-O3 or -Os), which makes the code run much faster, but also makes debugging harder (but not impossible). You can just go into the build settings in Xcode in the Debug configuration and temporarily turn up the optimisation level - this will keep all the other debug goodies (symbols etc) but hopefully also flush out the Release mode bug. (Don't forget to reset the optimisation level to -O0 in the Debug configuration when you're done!)

这篇关于如何在iOS中使用发布模式来调试问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆