我有一个程序在调试配置下在设备上运行良好,但在发布时失败。有人有过这样的经历吗?我该如何解决?
谢谢
最佳答案
我遇到了同样的问题 - 应用程序在 Debug模式下在模拟器和设备上运行良好,但在 Release模式下都运行良好(它会安装,但只显示启动屏幕)
- Xcode 4.3.2
- iOS 部署目标 4.3
我一直在 StackOverflow 上看到答案,说这是一个内存管理问题,但这对我来说没有任何意义,因为调试版本加载到我的 iPhone 4S 时工作得非常好。我还检查了“build设置”以了解两种模式之间的差异,并且我跳过了最终重要的一个差异 - 编译器优化。
在“build设置”->“Apple LLVM 编译器 3.1 代码生成”->“优化级别”下,将发布设置从默认的最快、最小 [-Os] 更改为无[-O0] 。解决了我的问题。
在此博文中找到了该解决方案:http://www.mindjuice.net/2011/11/30/how-to-fix-an-app-that-crashes-in-release-but-not-debug/ .
Apple Documentation有帮助,但不能解释为什么做相反的事情就能解决问题:
Code optimizations of any kind result in slower build times because of the extra work involved in the optimization process. If your code is changing, as it does during the development cycle, you do not want optimizations enabled. As you near the end of your development cycle, though, the release build configuration can give you an indication of the size of your finished product, so the Fastest, Smallest option is appropriate.
None: The compiler does not attempt to optimize code. Use this option during development when you are focused on solving logic errors and need a fast compile time. Do not use this option for shipping your executable.
Fastest, Smallest: The compiler performs all optimizations that do not typically increase code size. This is the preferred option for shipping code because it gives your executable a smaller memory footprint.
关于iphone - 应用程序作为调试运行,但在发布时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3327981/