views:

1537

answers:

3

What are the differences between debug and release builds for a Cocoa application? I know the debug version contains additional information for debugging but what else is different?

+10  A: 

Debug builds will contain debugging symbols which can be used by a debugger. Release builds often do not contain debugging symbols, so if you get a crash dump, all you'll get are a bunch of hexadecimal addresses instead of useful symbol names.

Debug builds are not compiled with optimization (-O0 with gcc), whereas release builds are compiled with optimization (typically -O2 or -O3). Optimization makes debugging much, much harder. If you attempt to debug a release application, the debugger will get very confused, since assembly statements no longer match up with HLL statements, statements get reordered, functions get inlined, loops get unrolled, etc.

Debug and release builds also defined different preprocessor symbols, and some code is conditionally compiled based on those (for example, array bounds checks, assertions, etc.), although that is highly application-dependent. A typical example would be to #define NDEBUG for release mode, which causes assertions to be removed.

Adam Rosenfield
A: 

In Tiger, Debug builds are "zero linked". This is it is optimized for you environment only and is not really a complete build.

cocoafan
A: 

Do I need to remove all NSLog entries for building in release or those are not taken into account in the release configuration?

That should be a separate question. http://stackoverflow.com/questions/ask
Peter Hosey