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.
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.
Related
I need to add some specific compiler flags only for certain files in my project. I did some googling and found out that this used to be possible in the file inspector in older Xcode versions. I'm on Xcode 8.1, however, and I can't seem to find where I can add custom compiler flags for certain files.
Could anybody please tell me how this is possible with Xcode 8.1?
Go to the navigation bar of your project
Click on your project
Click on the target you want to modify
Click on Build Phases
Look for the file you want to add the compiler flag in the Compile Sources list; in this list you should see two columns: name and compiler flags
Click on the latter column and a popup window should come up; add the compiler flags to that specific file
I am Code::Blocks 13.2 user in Ubuntu 14.04 LTS. How do I set the compiler options, such as compile under Debug or Release mode? I don't see the options readily on the GUI.
'Debug' mode and 'Release' mode are not compiler options. They are options in the
IDE for configuring the whole project (including the compiler options and
all other tool options) between debug mode and release mode.
In the tool bar beneath the top menu bar of the IDE you should see a drop-down menu
that has items Debug and Release for selecting the desired configuration.
See screenshot:-
What the various tool options will be in debug mode and release mode is up to you. The IDE has
sensible defaults. You can set them by navigating YourProject -> Build options
and selecting Debug or Release from the project tree-control of the left
before continuing. See Screenshot:-
To set up the compiler go to Settings->Compiler.
To set up your projects target settings (debug, release, etc...) right click on your project and go to build options.
You may also want to take a look at the over all project settings by also right clicking on the project and going to properties.
If your just editing files on their own you have to add them to a project first (otherwise why are you using an IDE in the first place?) by going to file->new->project
Settings ->Compiler->Global Compiler Settings->and there you can change your settings with flags or defines, and other options.
My documentation says
Click on the target and add pgmName.a on General settings of the
target Info.
I don't see a General settings, although I see Architectures, Build Locations, etc under build settings. And there's an info tab and a summary tab, but I don't see a General settings.
Xcode 4 no longer has this tab setup. You'll want to add pgmName.a to the Link Binary With Libraries step under the Build Phases tab of the target. If you're seeing Info and Summary tabs instead of Build Settings, Build Phases, and Build Rules, click on the target rather than the project in the left panel (under TARGETS rather than PROJECT.)
I'd like to be able to change compiler flags for a whole set of files.
When accessing per-file compiler flags from the "Build Phases" area you can change flags one at a time, however say I'd like to change the flags for every file in a group (e.g., the DropBox or Facebook SDK).
Anyone know how to do this in Xcode 4.0.x?
Fortunately, YES :-)
In Targets->Build Phaes->Compile Sources, mark all the files you like to set a compiler flag for, press RETURN (hit the enter key!), put the flag in the upcoming window and you're done!
I'm new to xcode and I must be missing something.
Create a new command-line project. Call it tempprog (for instance).
Select Project/Edit Project Settings.
Edit the name of the prefix header (tempprog_Prefixz.pch).
Build - it will fail, of course, looking for tempprog_Prefixz.pch
Now change the name of the prefix header back to tempprog_Prefix.pch.
Build again - it should work, but doesn't. It's still looking for tempprog_Prefixz.pch
Cleaning does not rectify the situation. What am I missing here? Where is the Prefixz.pch name being retained? If you look in the build output at the ProcessPCH command you can see that it still wants to use Prefixz.
It turns out there's a system of setting priorities.
From Working With Xcode Build Settings:
The levels at which build settings can be set, and their precedences are:
xcodebuild command-line flags (only applicable for command-line builds)
The target, editable via a target's Info inspector
The project, editable via a project's Info inspector
Xcode application settings, as set in Xcode > Preferences...
Xcode's built in defaults
The user environment, perhaps as set in a user's ~/.MacOSX/environment.plist file
Restarting your mac fixes the problem.