views:

74

answers:

2

I have an iPhone app that's been in development for about 2 weeks. We recently tried the "release" version of the build on a device, and to our great unhappiness, it crashes in one of the views with an "EXC_BAD_ACCESS".

This crash only occurs on devices, and only in the "release" build. Not only that, but it only happens the first time the app is launched! It is also 100% reproducible.

We have removed the small block of code that deals with data persistence, and have tried re-openning Xcode, cleaning the project, deleting and reinstalling the app, etc., as some other questions suggest.

Do you have any advice for a) what might be causing this problem, and b) how to go about debugging if it only happens in "release"?

Thanks

+1  A: 

We can only guess what the cause might but if it's 100% reproducible, then it should be a good candidate for some fprintf-style debugging.

Figure out the most probable place for the error to occur, and start putting "Got past xxx view initialization" style statements in to start narrowing the problem. It's tedious, but eventually, you'll get there.

In theory fprintf statements could affect the problem. However, it's rare that it does so, so it's a good place to start.

Wade Williams
Thanks Wade, I like that idea, and have used this technique before on other platforms. But will my app have permission to just `fopen(n,"w")` a file on the iPhone? I thought I wouldn't be allowed.
Chris Cooper
Honestly, I'm not sure Chris - but there's got to be some way to write data.
Wade Williams
Haha. Ok, I think that way is to jailbreak the iPhone and give yourself rights. ;D The iPhone only lets you write through it's framework calls, I believe.Thanks for your input though! This bug has me annoyed. =P
Chris Cooper
A: 

It turns out there was no problem in the code at all.

The reason it was crashing was that Xcode was trying to attach the debugger to the release build for some reason! We are still trying to figure out why, because we have checked the most obvious places, but I'm sure it won't be too hard to track down.

The build works fine if you install from iTunes or the Xcode organizer instead of building and running from Xcode directly, so it won't affect your end-users at all, as long as you are careful to check for other first-run issues.

Chris Cooper