Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 791
TalkingCode Avatar asked Apr 17 '09 18:04

TalkingCode


People also ask

What is the difference between debug build and release build?

The Debug configuration of your program is compiled with full symbolic debug information which help the debugger figure out where it is in the source code. Is Release mode is faster than Debug mode ? The Release mode enables optimizations and generates without any debug data, so it is fully optimized. .

What is the difference between debug and release mode?

Debug Mode: When we are developing the application. Release Mode: When we are going to production mode or deploying the application to the server. Debug Mode: The debug mode code is not optimized. Release Mode: The release mode code is optimized.

What is debug Xcode?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

Is debug slower than release?

In Debug mode, there are no optimizations, which means debug builds can run slower than Release build.


1 Answers

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.

like image 181
Adam Rosenfield Avatar answered Sep 22 '22 22:09

Adam Rosenfield