I have a project that has both an iOS and an OS X target. Is there a preprocessor macro that is true when I’m compiling for OS X? I tried this:
#if TARGET_OS_MAC
@interface BFNode : NSObject <NSPasteboardReading, NSPasteboardWriting> {
#else
@interface BFNode : NSObject {
#endif
But TARGET_OS_MAC doesn’t seem to work. When I try to run the app on iOS I get a compiler error, because it tries to compile the first line and there is no NSPasteboardReading protocol defined on iOS.
I know there is TARGET_OS_IPHONE too. If I use that and swap the @interface declarations it works.
But there are a lot of places where I have code, that has no iOS version, so I need a macro for OS X too.
SOLUTION:
I ended up defining a new macro in the .pch file:
#define TARGET_OSX TARGET_OS_IPHONE == 0
That is because
TARGET_OS_MACis defined when building for iOS as well.See http://sealiesoftware.com/blog/archive/2010/8/16/TargetConditionalsh.html on that.
I would try and build my own target specific define via build-settings on the target.