title: Creating an iOS/OS X cross-platform class
body: <p>I read a lot of questions about creating a cross-platform library for these 2 systems. Every answer points to static library as the solution.</p>
  
  <p>I don't want to end up with a static library, I'd like to create a class with methods for iOS and their counterpart for OS X.</p>
  
  <pre><code>-(void)createColor:(NSColor*);
  -(void)createColor:(UIColor*);
  </code></pre>
  
  <p>The first problem that I have is that I can't find a way to use classes that are available only in a specific system. So for example, how could I manage a function that works with <code>UIColor</code> in iOS and with <code>NSColor</code> in OS X?</p>
  
  <p>If I create a project for iOS, when I look into <code>Foundation.h</code> I can't find <code>NSColor.h</code> in the headers list. </p>
  
  <p>I thought to use the <code>TARGET_OS_MAC</code> and <code>TARGET_OS_IPHONE</code> definitions to make a distinction between the two systems... I'm on the right way? </p>
  
  <p><strong>EDIT to add more info:</strong> </p>
  
  <p>At the moment I have 2 targets: an iOSTestApp and OSxTestApp. For these targets I have included the needed frameworks depending on the system. </p>
  
  <p>Using <code>TARGET_OS_MAC</code> and <code>TARGET_OS_IPHONE</code> works only when I select the OSXTestApp as active target. When I select the iOSAppTest, Xcode returns errors for OS X data type (i.e. <code>NSColor</code>)</p>
  
  <p>Here an example of the code that produces these errors: </p>
  
  <pre><code>#if TARGET_OS_MAC
  -(void)createColor:(NSColor*)color;    
  
  #elif TARGET_OS_IPHONE
  -(void)createColor:(UIColor*)color;
  
  #endif
  </code></pre>
  
  <p>While if I invert the definitions it works ...
  Here an example of the code that produces these errors: </p>
  
  <pre><code>#if TARGET_OS_IPHONE
  -(void)createColor:(UIColor*)color;
  
  #elif TARGET_OS_MAC
  -(void)createColor:(NSColor*)color;
  
  #endif
  </code></pre>