title: Preprocessor macro for OS X targets?
body: <p>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:</p>
  
  <pre><code>#if TARGET_OS_MAC
  @interface BFNode : NSObject &lt;NSPasteboardReading, NSPasteboardWriting&gt; {
  #else
  @interface BFNode : NSObject {
  #endif
  </code></pre>
  
  <p>But <code>TARGET_OS_MAC</code> 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 <code>NSPasteboardReading</code> protocol defined on iOS.</p>
  
  <p>I know there is <code>TARGET_OS_IPHONE</code> too. If I use that and swap the <code>@interface</code> declarations it works. </p>
  
  <p>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. </p>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>I ended up defining a new macro in the .pch file:</p>
  
  <pre><code>#define TARGET_OSX TARGET_OS_IPHONE == 0
  </code></pre>