title: Objective-C Protocol Forward Declarations
body: <p><em>ObjectProperties.h</em></p>
  
  <pre><code>@protocol ObjectProperties &lt;NSObject&gt;
  
  @property (strong, nonatomic) NSString *name;
  @property (strong, nonatomic) NSDate *date;
  @property (assign, nonatomic) int64_t index;
  
  @end
  </code></pre>
  
  <p><em>ClassA.h</em></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @protocol ObjectProperties;
  
  @interface ClassA : NSObject &lt;ObjectProperties&gt;
  
  - (void)specialSauce;
  
  @end;
  </code></pre>
  
  <p><em>ManagedClassA.h</em></p>
  
  <pre><code>#import &lt;CoreData/CoreData.h&gt;
  
  @protocol ObjectProperties;
  
  @interface ManagedClassA : NSManagedObject &lt;ObjectProperties&gt;
  
  - (void)doSomething;
  
  @end;
  </code></pre>
  
  <p>From the code example above, I have defined a protocol in a .h file to be used with both Core Data objects as well as plain ol' vanilla objects. It seems like "noise" to have conforming classes ‪#import‬ the protocol in the their header; it would be cleaner to forward declare the protocol &amp; import‬ in the implementation file as I've shown above. However, Xcode throws a warning when doing it this way:</p>
  
  <p><code>Cannot find protocol definition for 'ObjectProperties'</code></p>
  
  <p>The code compiles, and mostly works. I say mostly because there's some funkiness with Core Data trying to dynamically create the getters / setters for the scalar property, but I think that's probably because I've hit an edge case.</p>
  
  <p>Of course, the most obvious work around is to just import the protocol header into the class headers.</p>
  
  <p>If my understanding is correct (and my knowledge is very recently acquired, and so it's entirely possible that I'm wrong), if I import the protocol into my class headers and make a change to the protocol, then all subsequent files that import my classes will have to be recompiled.</p>
  
  <p>What is the correct way to do solve this type of problem?</p>