44

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?

er.mobileapp
  • 1,287
  • 4
  • 15
  • 21

2 Answers2

53

I quote

"The biggest difference between these is that: In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account. While in release build the symbolic debug info is not emitted and the code execution is optimized. Also, because the symbolic info is not emitted in a release build, the size of the final executable is lesser than a debug executable.

One can expect to see funny errors in release builds due to compiler optimizations or differences in memory layout or initialization. These are ususally referred to as Release - Only bugs :)

In terms of execution speed, a release executable will execute faster for sure, but not always will this different be significant."

Courtesy of google and user mcdeeiis http://haacked.com/archive/2004/02/14/difference-between-debug-vs-release-build.aspx

This is a pretty solid explanation for all programming languages

Candyfloss
  • 3,848
  • 4
  • 31
  • 32
  • 3
    Thanks Ross Alexander for the link, it explains like some symbolic debug information will be generated in debug mode, what does that means exactly, where to view those info, will it be useful for clearing the errors, if so how to make use of it for debugging and clearing the errors, can you explain an instance. – pradeepa Mar 11 '11 at 08:48
  • 3
    Symbolic debug information: info that links binary info to source code. Such as line numbers, variable names etc. Allows you to debug your code with reference to your source code. In terms of debugging this of course helps but you are already using this info without realizing :) I believe you can turn this info on in release mode as well as a setting in Xcode but dont quote me on that :P as I'm not in front of Xcode at the moment – Candyfloss Mar 11 '11 at 08:55
  • :) i may have to study compiler design to understand these things, thanks anyways.:) – pradeepa Mar 11 '11 at 09:11
  • 1
    There is no reason to include debug symbols in release code. If you have used Build&Archive the Xcode organizer can symbolicate crash logs for you. – Matthias Bauch Mar 11 '11 at 09:11
  • http://developer.apple.com/tools/xcode/symbolizingcrashdumps.html you may find this link helpful, and fluchtpunkt is correct however you can build two versions a release and a release with debugging. This is handy sometimes to have – Candyfloss Mar 11 '11 at 09:15
  • I guess this doesn't really answer the question. I guess the question was more about why isn't there a debug/release drop down menu in xcode, and how do you know generated code will be debug or release. It's especially more ambiguous when you compile libraries which are cross platform and are not apple-specific, so they often use other kinds of tools to generate xcode files which you can compile. I'm using bullet physics, and xcode is ignoring my lib because it doesn't have the correct binary format. "file was built for archive which is not the architecture being linked" – jokoon Aug 22 '12 at 01:03
  • Is debug only used when you set breakpoints or is it always when you run the app? Is release only used when you archive to push to the appstore or when is that used? Because when I create a new standard project in xCode the default scheme creates in debug. But I don't find a scheme that uses release.. – user1007522 Dec 15 '14 at 13:29
  • @Matthias: Those symbolicated crash logs from builds without debug information don't contain line numbers, making them a lot less useful than the ones of builds that contain debug information. As naturally crashes on end user devices usually happen in release builds, it can be preferable to build release builds with debug information included - the difference to just shipping debug builds is still the optimization setting. – Kaiserludi Sep 20 '17 at 13:10
3

The release version is more optimized for better performance and smaller size.

Also from personal practice I can say that it's useful to turn on more warnings in release configuration to know which methods are not used, which methods don't have declaration where signed/unsigned are being compared as well as other useful stuff.

Eimantas
  • 48,927
  • 17
  • 132
  • 168
  • 1
    Why wouldn't you turn those warnings on in Debug mode, as well? – Cody Gray - on strike Mar 11 '11 at 08:35
  • Since they are more pedantic than functional - it's nice to have warning free code for me. – Eimantas Mar 11 '11 at 08:40
  • 1
    I prefer to have warning-free code in *Release* mode. It's much more important there than it is in Debug mode. If I fix the bugs in Debug mode first, they'll be gone when I switch to Release mode. More importantly, "pedantic" issues like that indicate design flaws in your code—you need to fix those at design/debug time, not once you're ready to test/release. – Cody Gray - on strike Mar 11 '11 at 08:42
  • 2
    They are pedantic because they want to signal you some (potential) problem which you should fix. If you turn them on while developing they're most of the time easy to fix as soon as they turn up the first time. – DarkDust Mar 11 '11 at 08:47