iphone - 应用程序作为调试运行,但在发布时崩溃

标签 iphone cocoa-touch xcode

我有一个程序在调试配置下在设备上运行良好,但在发布时失败。有人有过这样的经历吗?我该如何解决?

谢谢

最佳答案

我遇到了同样的问题 - 应用程序在 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/

相关文章:

iphone - 旋转 View 不会旋转音量按钮图标

iphone - 如何在 UIWebView 中同时播放两个视频

iphone - 错误: Number of Rows In Section in UITableView in iPhone SDK

iphone - 使用非零原点初始化 UIImageView 的更好方法

xcode - 在 mac osx 中获取 usr/local 路径

iphone - 如何使用指定的 UIViewController 启动应用程序?不是第一个

iphone - 如何绘制条形图和饼图 iPhone sdk?

ios - 来自类文件的可拖动图像

ios - 崩溃没有警告xcode

ios - 导入混合框架时在 iOS 应用程序中找不到 Swift 类