In Xcode, all the target's build settings inherit from the project's build settings. The project's build settings inherit from "iOS Default". This inheritance is shown below with Levels selected rather than Combined.
For those who were not aware, the bold entries under the project's settings indicates an override. The override can be "cleared" by highlighting the setting and then pressing COMMAND-BACKSPACE.

It gets really old constantly changing those values for every non-trivial project I create. Especially items like Other C Flags, where I have to add -Wall -Wextra -Wconversion -wstrict-overflow. Preprocessor Macros is another which must always be fixed to include Posix's NDEBUG=1. I definitely consider lack of NDEBUG=1 in Release builds a bug since Posix requires NDEBUG to remove abort() caused by assert(); and Apple's UI standards don't allow an abort(). (DEBUG=1 is similar for Debug builds since so many use it despite the fact Posix only standardized NDEBUG).
From @Petesh below, I know I can use a Configuration for each project (perhaps create it once, and re-use it). But that means I am applying "proper" or "correct" setting to mask defective settings in the "IOS Default" template. My intention is to fix the problem at the source of the problem once and for all.
How does one edit the default setting template? Is there a physical file on the file system that represents "iOS Default"? If so, can it be edited (is it XML)?
UPDATE: Based on @Peresh's answer (there is no disk file to permanently fix the problem): RADAR 12941954. It will probably sit in Apple's bug reporting system unconfirmed, unanswered, and unfixed for years, just like the rest of the bugs folks like me and others take the time to report.
Build configuration files are an ideal way of choosing a set of options for preprocessing/compilation - you use .xcconfig files with the settings that you want to have as a base, then choose this base configuration for the targets.
The file needs to be created at the base of the project, with the name TargetType.xcconfig. For your base compiler flags requirement, you can use a file with the content:
OTHER_CFLAGS = -Wall -Wextra -Wconversion -wstrict-overflow
Once you base the target on the .xcconfig file, it will get those options as default items for all the targets specified.
You can add one for each of Debug and release, allowing the specification of the NDEBUG=1 and DEBUG=1 options e.g.
GCC_PREPROCESSOR_DEFINITIONS = NDEBUG=1
will apply this setting to the configuration.
Look at the Xcode help for Basing a Build Configuration on a Configuration File. There's also a tutorial online that goes through the process.
I've used gcc/g++ spec files for manipulating the default compiler options for gcc. This still works if you're using the gcc driver for LLVM. The default compiler options are those from the unmodified spec file - i.e. it's built into the compiler, and does not reside on disk. The process is:
gcc -dumpspecs > specs
specdir=$(gcc -print-search-dirs | sed -n 's/install: //p')
sed 's/^\(.*mdynamic-no-pic:-fPIC\)/<default options here> \1/' specs > newspecs
sudo cp newspecs $specdir/specs
You can verify that the specfile is being used by doing:
gcc -v <file>
and it should display something like:
Reading specs from /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/specs
rather than
Using built-in specs.
This can trigger confusion as these flags will affect all gcc/g++ compilations - even for macports packages, which means that they may not compile correctly.
clang/clang++, unfortunately has no concept of the specfile, and as such will ignore this file when compiling - all the options that it uses are defined at clang build-time. There is no way of manipulating the default compiler options in this case as it makes no attempt to read a file on-disk to determine default compiler options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With