Xcode / Cocoa : What are the differences between debug and release builds


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?

Best Solution

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.