Re: Setting Conditionals in Targets
Re: Setting Conditionals in Targets
- Subject: Re: Setting Conditionals in Targets
- From: Eeyore <email@hidden>
- Date: Wed, 20 Oct 2010 19:31:17 -0700
When you put stuff into the compiler flags, it is passing that stuff on to the compiler as if it were invoked from the command line, so setting -xyz for the file foo.c invokes something like
gcc -xyz foo.c
To set preprocessor definitions, use "-" followed by an upper case letter "D" for define and then the thing you are defining for setting (-Dxyz as suggested in another post, or -Dxyz=1 if you want to define it to be 1). If you want to toggle warnings using compiler flags, you would do something like "-Wall" which would toggle "all (reasonable) warnings". Use man gcc in the terminal to get a whole bunch of goodies that can be set this way.
You can see probably see the results of this in the Build Results window (you can learn all sorts of stuff trying to decipher this log). Here's what I get for one of my files when I invoke it with -xyz added to the file's Get Info. Notice that it appears that -xyz attempted to set the language I was compiling to "yz"
CompileC build/iSplit.build/Testing-iphoneos/Tests.build/Objects-normal/armv6/MWDatabaseTests+Race.o Test/Database/MWDatabaseTests+Race.m normal armv6 objective-c com.apple.compilers.gcc.4_2
cd /Users/eeyore/Developer/iSplit
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch armv6 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -Os -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -gdwarf-2 -mthumb -miphoneos-version-min=3.0 -I/Users/eeyore/Developer/iSplit/build/iSplit.build/Testing-iphoneos/Tests.build/Tests.hmap -F/Users/eeyore/Developer/iSplit/build/Testing-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/Developer/Library/Frameworks -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/Developer/Library/Frameworks -I/Users/eeyore/Developer/iSplit/build/Testing-iphoneos/include -I/Users/eeyore/Developer/iSplit/Libraries/OCMock/Headers -I/Users/eeyore/Developer/iSplit/build/iSplit.build/Testing-iphoneos/Tests.build/DerivedSources/armv6 -I/Users/eeyore/Developer/iSplit/build/iSplit.build/Testing-iphoneos/Tests.build/DerivedSources -DCONFIG_Testing -DNS_BLOCK_ASSERTIONS=1 -DNDEBUG -xyz -include /var/folders/j9/j9cBuMV5G6O6F84qoaP-pk+++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/prefix-ejqojksotqscwvfmqrzbynluabqp/prefix.pch -c /Users/eeyore/Developer/iSplit/Test/Database/MWDatabaseTests+Race.m -o /Users/eeyore/Developer/iSplit/build/iSplit.build/Testing-iphoneos/Tests.build/Objects-normal/armv6/MWDatabaseTests+Race.o
arm-apple-darwin10-gcc-4.2.1: language yz not recognized
arm-apple-darwin10-gcc-4.2.1: language yz not recognized
arm-apple-darwin10-gcc-4.2.1: /Users/eeyore/Developer/iSplit/Test/Database/MWDatabaseTests+Race.m: linker input file unused because linking not done
Aaron
On Oct 20, 2010, at 7:02 PM, Gordon Apple wrote:
> After some more research, I did find that you can supposedly select a file,
> click Info, and set compiler flags for a target. However, I could not get
> it to work. I added "-xyz". (Don't ask me what the "-" is for. it won't
> compile without it.) But if I put an "#ifdef xyz" into the code, it ignores
> it. So I'm still doing something wrong.
>
>
> On 10/20/10 3:34 PM, "Jonathan Prescott" <email@hidden> wrote:
>
>> You can double-click on the target, right-click to "Get Info" on the target,
>> and under the Project Menu setting, edit the active Target, which is the
>> current target selected in the various Xcode drop-down bars. All of these
>> action bring you to the target editor, which will allow you to modify the
>> build settings for that particular target.
>>
>> If you want to change compile settings for a specific file in a specific
>> target, even if it's the same file used in another target, I'd like to know if
>> that's possible as well.
>>
>> Jonathan
>>
>> On Oct 20, 2010, at 4:22 PM, Gordon Apple wrote:
>>
>>> I haven't used multiple targets previously, and am trying to figure out how
>>> to differentiate them with conditional compiler flags. The CFLocalServer
>>> example is useless in this regard because it only deals with selected files.
>>> I thought I remembered being able to set flags in either the project
>>> settings or the target settings, but can't currently find it. I want to be
>>> able to use the same file in two targets, but with conditionals that
>>> automatically specify which target is chosen. What is the best way to do
>>> define the necessary flags in the settings? Do I need to specify different
>>> configurations?
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Xcode-users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden