iPhone release build is crashing
A project i'm working on is crashing when built with release co开发者_StackOverflow社区nfiguration.
We need to send the application to apple for review and it is crashing before even entering the app.
Any idea how that could happen?
In last ressort, is it possible to send to apple a debug version of the app with some optimizations?
thanks.
The same thing happened to me when building my first iPhone app - after working on the project for a while when switching from debug to release the app would crash. I did a full clean rebuild of the project, deleted the app from the test phone and reinstalled it, and the app ran. It looked like XCode sometimes does not clean up/rebuild everything it needs to.
In my experience, 9 times out of 10 annoying, hard to track down crashes in a non-debug vs. debug build of anything, iPhone or otherwise, is caused by a memory management bug. I'd put money on your issue being caused by an improperly placed release or retain message, or lack thereof. If you haven't tried it yet, turn on the static analyzer in your debug build configuration (my XCode is updating right now, but I believe if you search for "analyzer" or "clang" in your build properties you should find the appropriate setting) and see if it points to anything telling. If it doesn't, you can use Instruments to help you check for problems, as well as attempting to isolate the problem area in the debugger.
It might help you to reproduce the problem in a not-actually-a-release-build by modifying your debug configuration or duplicating it to use a different set of compiler flags that more closely aligns with what happens in the release build (I don't recall what the differences are off the top of my head, but I would assume adding a "-O2" to your compiler flags would get you most of the way there).
If you build with Release configuration, make sure you keep a copy of the .dSYM file and the application bundle.
Then when the application crashes on the device, plug it into Xcode and download the crash reports.
Open Xcode and then open the Organizer from within Xcode. From there you can view crash reports from a device.
The crash reports will be symbolicated if (and only if) you saved the .dSYM file and the application bundle.
You can then use the crash reports to find out why it is crashing, and fix it.
You should look at your Crash Logs. Open Organizer, select your device, then the "Crash Log" tab. Scroll down to find your app's logs. The should be symbolicated, so you can see the stack trace.
Without actually debugging your app, it's really hard to say more. Are you using an #ifdef DEBUG macros? Are you using more than one thread? If you have a bunch of NSLog statements that slow down execution in debug mode, this can introduce subtle timing differences that can impact multi-threaded apps.
Did you try a 'make clean' on your debug version? Sometimes obscure bugs can be hidden when parts of your project are rebuilt while other parts are unchanged.
精彩评论