Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

ios - App crashes in Release build but not in debug

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]
}

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...