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?
Xcode / Cocoa : What are the differences between debug and release builds
cocoadebuggingxcode
Related Topic
- C# – How to remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning
- .net – “The breakpoint will not currently be hit. The source code is different from the original version.” What does this mean
- C# – Performance differences between debug and release builds
- Iphone – Xcode Difference between debug and release
- Ios – Version vs build in Xcode
- C# – Writing to output window of Visual Studio
- Java – Unfortunately MyApp has stopped. How to solve this
Best Answer
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.