Turning on 'DEBUG' macro value - iphone

In my code, I want to conditionally perform a few operations with:
#ifdef DEBUG
NSLog(#"I'm in debug mode");
#endif
I've configured Project->Edit Project Settings->Build tab so that 'DEBUG' is listed as a User-Defined setting with a value of 1. Debug is selected in the Configuration dropdown. This still doesn't turn on the directive for the Debug build although I thought that's what it would do.
What else do I need to do during the build stage to allow for this?

You need to set a compiler flag for that.
To do it, Get Info on the target, make sure you have selected the Debug configuration (and not All Configurations), and look for Other C Flags and Other C++ Flags (in Xcode 3.1 these are under GCC 4.2 - Language).
Then add the following as a value: -DDEBUG for both.
This will define the DEBUG for the precompiler to pick it up.

project -> settings -> c/c++ (or code generation?) look for a text box labeled Preprocessor Definitions and just add DEBUG to the end of the comment separated list.

The above solutions seem like SDK 3.0 solutions, I'm still living in a 2.2.1 world with XCode 3.1.
This link did the trick for me, complete with pictures!

Related

How do I define preprocessor macros in Xcode 4?

I have two targets set up for my app (a lite version and a pro version) and I want to integrate some subtle differences in the code for each of them (e.g. the pro version will not show any iAd banners).
I have been looking around and I see the easiest way to do this is through the use of preprocessor macros. The issue I'm facing is how to set them up in Xcode 4. I want to set up a macro called 'PRO_VERSION' in one target & 'LITE_VERSION' in the other.
Below is an example of how I intend to use them:
#ifdef PRO_VERSION
// Hide ad banners
#else
// Show ad banners
#endif
The build setting you need to change is called 'Preprocessor Macros' and it can be found in the 'Build Settings' tab of the Project Settings pane (use the search box to find it). Select each target in turn in the left-hand side of the Project Settings pane then modify the Preprocessor Macros setting.
The setting is specified as a space-separated list of preprocessor macros in the form 'foo' or 'foo=bar'.
I'm not on my mac at the moment, so I can't give full step-by-step directions, but I believe this should be accurate, if not as detailed as I would otherwise be. Create a new build target. Go to the configuration screen for this new target. There should be a tab along the lines of compilation options. In this tab there should be a row for other compiler flags. In there, put -DPRO_VERSION.

XCode 3.2.4 Project - no "other linker flags" in build settings visible

I am recently trying to connect my cocos2d game with open feint, but I can't accomplish it as there seem to be some settings missing in my build settings of any project that I create.
For example, I have to check "Call c++ Default ctors/Dtors in objective c", but there isn't such an option in my build settings. What's wrong with that?
Here is a picture:
http://img413.imageshack.us/img413/3425/bildschirmfoto20101023u.png
My project is the one on the left, I downloaded the right one. I need to my build settings to like like the ones on the right. Is that somehow possible?
In the image, you have the build settings windows set to show "settings defined at this level". Since you haven't yet changed the other linker flags setting, naturally it doesn't show up. If you show all settings, you should see it.

Xcode, no debug symbols for certain subclass

I'm using Xcode 3.2.3 and iPhone SDK
So I'm trying to debug a UIView subclass, I hit a breakpoint in an overridden method and I can't see any symbols in either the GUI or gdb, just globals and registers.
This is what I see:
(gdb) po self
No symbol "self" in current context.
Yet when I set a breakpoint in a UIViewController subclass, all the symbols are there:
(gdb) po self
<MyViewController: 0x5c18ae0>
Current language: auto; currently objective-c
Some things I've tried:
clean all/rebuild
restart Xcode
change between debug and release
config these options in Project
settings:
GCC_DEBUGGING_SYMBOLS = All
Symbols DEBUG_INFORMATION_FORMAT = DWARF, DWARF w/ dSYM File
BUILD_VARIANTS = normal, debug
threatening Xcode by swearing at it and typing
rm -rf /Developer into a root bash prompt
Please help, my fingers are bleeding from debugging with NSLog
I experience this bug often. My workaround is typing the bt command on the gdb console, it then automagically sorts itself out and starts recognizing symbols in the current context.
So changing from Debug to Release did the trick and I have all my debug symbols.
I think it's just a bug in the 4.0 SDK.
Hmmm, tried to repro this in 3.2.3 and SDK4 Final with no success -- able to debug UIView subclass as expected. Is this occurring using one of the beta releases?
Happening to me, on a non-beta release. I just noticed that it only occurs when calling a class-defined method, ie (+) not (-)
I wouldn't mind not having a "self" pointer, but it also seems to wipe out all local variable displays in the debugger, and that is just wrong.
MTS' method worked for me. Changing from debug to release fixes this issue. How strange. I can disprove software evolved's theory, as I experience the error inside an instance method.
in gdb type bt.
If you see self=<value temporarily unavailable, due to optimizations> anywhere it's because xcode has been set to be optimized.
Go to the build settings and type optimization.
If optimization level for either debug or release is set to Fastest that's causing your issue.
Release should be left at fastest so your code run well when building for distribution. It's better to change your Build Configuration in Scheme.
opt+click the Run button. On the left click Run YourAppsName.app, then Info and select debug.

Xcode: Setting GCC_PREPROCESSOR_DEFINITIONS for different build configurations?

I want to set GCC_PREPROCESSOR_DEFINITIONS for each of my four build configurations (Debug, Release, Ad Hoc, and Distribution.) I'd like to have a different setting for each.
The screen I'm looking at is the Target Info window's "Build" tab. When I set the Configuration pop-up to "Debug" I can see my GCC_PREPROCESSOR_DEFINITIONS setting there. When I switch to "Release," or any of the other configurations, it's no longer visible. Yet when I try to add it to those configurations, it says GCC_PREPROCESSOR_DEFINITIONS already exists, and that I can't add it again.
As I said, I want to have a different setting for my various builds. How can I accomplish this?
Thanks very much.
Make sure there isn't a setting called "Preprocessor Macros". This is the same as GCC_PREPROCESSOR_DEFINITIONS.
OTHER_CFLAGS if I understood the question right. And pass your defines like -DDEBUG or something.
And yes, if you need to assign a value to a macro, you could do something like this - '-DSOME_MESSAGE=#"Hello, World!"'.
Note ' symbols around - they are required. SOME_MESSAGE macro will be defined with #"Hello, World!" value.

Setting GCC 4.2.1 options in Xcode

I have a few questions about Xcode and interaction with GCC 4.2.1:
It doesn't seem as if Xcode Target Properties inspector exposes all possible GCC options. Is this correct?
More specifically, I'm interested in setting the "mfpu" option, as mentioned in the arm_neon.h intrinsics header. Is this possible or supported? Or perhaps set as a side-effect of some other Xcode setting?
If anyone has tried this or can post some resources, it would help a lot.
There are not checkboxes or menus available each option presented by the compiler, however you can enter any flags you'd like passed to the compiler in the "Other C Flags" field of the Target inspector.
Just set "Other C Flags" to "-mfloat-abi=softfp -mfpu=neon" and you'll be set.