1

I'm working with XCode 4.6 on MAC OS X 10.8.

I'm new to this IDE and platform. I have a project I compile and optimizations are turned off by XCode.

It doesn't matter if I set Release Scheme.

I saw at the thread named "Cannot Disable Debugger with XCode 4.5" that it has to do with the flags '-O0' and '-Os'. I know that some flag set "Debugging Mode" which means no optimization is done and more data is generated by the code to help debugging. I just can't find the single parameter which controls this behavior in XCode (Like /Mtd in VS).

Which parameter in the XCode options controls this parameter?

Moreover, In VS it is easy to see the build parameters as a command line (Under options, both Linker, and Build). Where can I see that in XCode?

Thanks.

Community
  • 1
  • 1
Royi
  • 4,640
  • 6
  • 46
  • 64

1 Answers1

6

All the compiler and linker flags can be found within a project's or a target's "Build Settings" (targets can overwrite their projects' settings). To get there, select the project file, then select your current target, and go to "Build Settings". Select "All" and "Levels" at the top to display all available options and where they are set (project or target -- left-most wins).

The options are grouped, e.g., linker options and compiler options, and most of them refer to flags. Xcode shows a descriptive name rather than the full flag name. To see the latter, select the line of interest and select the "Quick Help Inspector" in the right panel ("Utilities" panel). The flag you seem to look for is called "Optimization Level" in Xcode.

You can set each option's value, and Xcode may display some meta information next to the raw value, e.g., "Fastest, Smallest" for -Os, or "None" for -O0. You can set all options for each configuration (by default, Release and Debug) independently. Which configuration is actually used depends on your build action. If you build & run, Debug is used by default. If you archive an application, Release is used by default. However, you can change most of that by editing the schemes.

Update: To get an idea of the differences between the Release and Debug configuration, look at the "Build Settings" of a given target. If an option's value differs in both configurations (or any other configuration you may have), there's an arrow in front of the option's name which indicates the differing values. E.g., take the "Build Active Architecures Only" setting. In debug mode, it assumes you build for a particular testing device so there's no need to include code generated for other platforms as well. However, if you build your app for distribution, you want to build one app that includes code for all target devices/hardware architectures.

Other options to look into: -Debug Information Format: The way debug information (crash reports) are stored. In Release mode, this is set to "DWARF with dSym", which means that your crash reports are encrypted so no one else can get meaningful information (symbol names) out of them.

-Strip Debug Symbols During Copy

-Optimization Level, as mentioned above

-Preprocessor Macros: This allows you to make your code (statically) dependent on the build configuration, e.g., to log only in Debug mode

Xcode provides more (and probably more accurate) information on all these options in the above-mentioned "Quick Help Inspector", just select any option.

From my experience, despite the optimisation, Release builds are often faster (i.e., they build faster) and definitely smaller in size.

hagi
  • 11,503
  • 3
  • 35
  • 48
  • Thank you for your answer. What, parasitically, differs Debug from release mode? Which settings tell the compiler to add data required for the debugging stage? Thanks. – Royi Apr 03 '13 at 10:48
  • Thank You. Though I still couldn't find how to see the exact command line created by all chosen settings (Something like 'msvc example.c /O1 /sse3') I could easily find on Visual Studio. I'd be happy to have more data. Think of I don't use XCode templates, but build one by myself. What would I do different? Again, Thank you and I marked your answer as a valid answer. – Royi Apr 03 '13 at 19:52
  • 1
    You can see which flags have been used/passed if you go to the "Log Navigator" (left panel). Select the "Build " section, and you will see an overview of the build stages. On the very right of the "Compile " stage, you can see a list icon. Select it, and you will see the full command including all output. Same holds true for the other build stages. – hagi Apr 03 '13 at 20:15