#define DEBUG, RELEASE

Member
Posts: 31
Joined: 2009.01
Post: #1
Are there any global #defines like there are in win32 for the different build targets?

I'm looking for the equivalent of #define _DEBUG

Thank you in advance
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
I'm not sure if Xcode automatically defines any, but if it doesn't, you could easily add -DDEBUG to OTHER_CFLAGS in your debug target.
Quote this message in a reply
Member
Posts: 31
Joined: 2009.01
Post: #3
Yes this is exactly what I want, however I can't find it. I screwed around with some user-defined group which didn't work.

Any additional help? Screen grabs, steps, anything?

Thanks
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
Try this:

1) launch Xcode. Before you do anything, make it suck less by going to Preferences and using the All-In-One layout.
2) New Project, using whichever template you want, like Mac OS X Cocoa Application.
3) click the Build tab, and then the third tiny icon at the lower left of the build panel ("show build transcript", if you hover over it to see the tooltip.) This will show you what Xcode is actually doing. It's just a GUI on top of gcc, and you want to see the flags sent to gcc.
4) Cmd-B to build. With the default Debug configuration, you'll see something like
Code:
CompileC build/foo.build/Debug/foo.build/Objects-normal/i386/main.o /Users/...
    /Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 ... -Wunused-variable -isysroot ...
5) double-click the project icon at the top of the Groups & Files pane on the left.
6) go the the Build tab. Here's where you can change or add compiler flags. There are a lot of them. The "Research Assistant" button at the bottom of this panel will show you the real gcc name for each item, and a description of what it does.
7) the "Configuration" popup at the top of this panel lets you change settings differently for Debug/Release. Choose Debug.
8) In the "GCC 4.0 Preprocessor" section, edit "Preprocessor Macros" and add "DEBUG". Xcode will automatically add -D for you.
9) Cmd-B again. You'll see something like
Code:
CompileC build/foo.build/Debug/foo.build/Objects-normal/i386/main.o /Users/...
    /Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 ... -Wunused-variable [b]-DDEBUG[/b] -isysroot ...
Quote this message in a reply
Member
Posts: 31
Joined: 2009.01
Post: #5
arekkusu, you sir are a god.

Thank you so much!
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #6
Hmmm... I can't seem to locate a "GCC 4.0 Preprocessor" section in my project. Any idea what would cause it to NOT be there?

There is a section near the bottom, labeled "User-Defined", that has a few GCC-looking definitions, though.

The only other setting I can find that refers to GCC is in the "Compiler Version" section, where the "C/C++ Compiler Version" setting is set to "GCC 4.0".
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
My description was written using Xcode 3.1.2 from the iPhone 2.2 SDK. Earlier versions of Xcode may be slightly different.

The search field in the Build configuration panel will let you find a preprocessor setting, wherever it might be. "Other C Flags" is also OK for adding arbitrary defines.
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #8
arekkusu Wrote:My description was written using Xcode 3.1.2 from the iPhone 2.2 SDK. Earlier versions of Xcode may be slightly different.

The search field in the Build configuration panel will let you find a preprocessor setting, wherever it might be. "Other C Flags" is also OK for adding arbitrary defines.

I'm running Xcode 3.1.2 with the 2.2 SDK (haven't installed 2.2.1 yet). I was checking in an iPhone project, GLSprite to be exact and couldn't find those settings. When I created a new Mac OSX project, those settings were there. So I tried creating a brand new iPhone project (view controller based) and the setting aren't there.

I'm wondering what rhyme or reason there is for these particular settings being available or not. Anyone have any ideas?
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #9
kalimba Wrote:I'm wondering what rhyme or reason there is for these particular settings being available or not. Anyone have any ideas?

Well, I think I figured out what's going on. If I switch my project's "Active SDK" to any Simulator configuration and check the Build settings in the Project Info, I get none of the GCC 4.0 options. If I switch the project's Actve SDK to a device configuration, the CGG 4.0 options are suddenly available.

What's up with that? Huh
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Changing Configuration from "Debug" to "Release" causes Graphics Bugs Bersaelor 6 4,088 Jun 28, 2010 06:30 AM
Last Post: Skorche
  adhoc different then device debug? kendric 8 4,856 Jan 15, 2010 11:42 AM
Last Post: kendric
  app crashes in non-debug environment Gillissie 2 2,968 Dec 12, 2009 05:03 PM
Last Post: DoG
  Define Random Integer (Best Way) 9livesoftware 2 3,038 Sep 24, 2009 11:09 PM
Last Post: Bachus
  Debug Break Code haudio 4 3,652 Jan 21, 2009 11:50 PM
Last Post: haudio