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?
views:
1537answers:
3Debug 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.
In Tiger, Debug builds are "zero linked". This is it is optimized for you environment only and is not really a complete build.