应用程序在发布版本中崩溃但在调试中没有崩溃 [英] App crashes in Release build but not in debug

查看:98
本文介绍了应用程序在发布版本中崩溃但在调试中没有崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我在标题中所说,我正在为iPhone编写一个应用程序,它在调试模式下运行完美,但当我将其构建为发布并通过TestFlight安装时,它会崩溃。
由于崩溃日志,它可能需要对这些行做一些事情:

As I said in the title, I am writing an app for iPhone which runs perfectly in debug mode but when I build it as release and install it via TestFlight, it crashes. Due to the crash log it might have to do something with this lines:

let path = NSBundle.mainBundle().pathForResource("PrinterList", ofType: "plist")
if path != nil {
    let printerDic = NSDictionary(contentsOfFile: path!)
    let printerList = NSArray(array: printerDic.allKeys)
    printerNames = printerList as [String]
}

我是使用Brother的框架在没有AirPrint的情况下打印,但我认为这不是问题,因为应用程序在使用框架之前崩溃了。
它只在我执行这些行的ViewController中崩溃。我也只需要在这个ViewController中使用框架。

I am using an framework from Brother to print without AirPrint, but I think thats not the problem because the app crashes before doing something with the framework. It crashes only in this ViewController where I execute these lines. I need the framework only in this ViewController as well.

推荐答案

应用程序在发布模式下崩溃的原因有很多但不是在调试模式下(例如,内存分配差异显示两个版本中实际存在的错误。)即使使用非beta编译器/语言,它们也可能需要大量工作才能跟踪。

There are many reasons that an app might crash in release mode but not in debug mode (e.g. memory allocation differences showing up a bug that actually exists in both builds.) They can take a lot of work to track down, even with a non-beta compiler/language.

你说如果按照我的建议去做,并且在关闭优化的情况下构建发布版本,问题就会消失。鉴于Swift编译器仍处于测试阶段并且肯定仍然存在偶然问题 - 我已经看到编译器在构建优化版本时会崩溃 - 这实际上可能是一个优化器错误。

You say that the problem goes away if you do as I suggested and build for release with optimisations turned off. Given that the Swift compiler is still in beta and definitely still has the occasional problem—I've seen the compiler simply crash when building optimised builds—this may actually be an optimiser bug.

因此,现在,我推迟调查。在我们获得编译器的完整发行版之前,无需优化即可发布。然后,重新启用优化并查看是否仍有问题。如果你这样做,那是开始花费精力的时间,试图弄清楚它是编译器错误还是你自己代码中的错误。

For now, therefore, I'd defer looking into it. Release without optimisations until we get a full release version of the compiler. Then, turn optimisations back on and see if you still have the problem. If you do, that's the time to start spending your energy trying to figure out if it's a compiler bug or a bug in your own code.

这篇关于应用程序在发布版本中崩溃但在调试中没有崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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