XCode Multiple Targets question

Apprentice
Posts: 7
Joined: 2008.06
Post: #1
Hi,

I have two targets defined in XCode (one for free app, the other for full).

in my application logic, I want to use something like

#ifdef FREE_VERSION_OF_MY_APP
// display ads
#endif

or something similar, is there I way I could specify some variables for targets like this? (I tried using header files, can't use them, XCode pulls value from the header that it finds using its on search mechanism, doesn't care for which header file is included in the target's "Copy Resources" group).

--
Regards,
MI
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
A few things:
  • You can define compile-time constants with the -D argument to gcc (like gcc -DFREE_VERSION_OF_MY_APP or gcc -DFREE_VERSION_OF_MY_APP=1).
  • When you #include or #import a header file, gcc searches through your defined header search paths (somewhat differently if you use <foo.h> vs. "foo.h") and essentially pastes the contents of the first one it finds into your source file in place of the #include statement. If you want to include different headers for different targets, you could pass different header search paths to each.
  • Header files are not resources. There's no (non-esoteric) reason to ever include them with your built executable. Always leave them out of the Copy Resources group.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #3
In Xcode, you can open the target's build settings, and add FREE_VERSION_OF_MY_APP next to Preprocessor Macros.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Xcode 4 OpenGL Game Template Question Macmenace 4 6,673 Mar 19, 2012 06:03 PM
Last Post: Macmenace
  XCode question kendric 3 3,038 Apr 30, 2009 02:55 PM
Last Post: OptimisticMonkey
  a small question (xcode button actions) imaumac 3 4,290 Oct 14, 2008 10:03 PM
Last Post: imaumac