Debugging Release Version

We've been running into some random issues after archiving and exporting a release version, that NEVER happen in debug mode. How do you track down something like that?

In my experience problems like this are often caused by memory management issues, so I generally start out by taking the usual memory management debugging steps:

  • enable all the compiler warnings and fix anything that it complains about

  • fix any issues reported by the static analyser

  • run the app with zombies enabled

  • run the app with address sanitiser enabled (a new feature in Xcode 7)

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Turn on the Debug Random Issues flag (just kidding ;-).


If you want to run in Release mode then just do that. Under Edit Scheme > Run change the Build Configuration to Release. Then run in the debugger like normal.


If your issues don't appear when running in Release mode under the debugger but do appear in adhoc builds then you're likely in for some printf debugging.


If your issues really seem to be random then how do you know that they don't occur in Debug mode? I'm not trying to argue but merely to suggest that you keep an open mind. It could be a compiler bug but it's more likely a bug revealed by the optimizer.

Note that while the debugger is certainly functional in optimized builds its behavior can be quite surprising. Aggressive optimizations can cause lines to execute out of order or be skipped altogether, and can change the scope and storage of data sufficiently that the debugger may be unable to represent it just when you'd find it most useful.


So long as you're aware of the limitations, applying the debugger to an optimized build can be extremely valuable.

Debugging Release Version
 
 
Q