title: Cannot find protocol declaration for
body: <p>I have two objects, both of which are view controllers. The first (Ill call it viewController1) declares a protocol. The second (which unsurprisingly I will name viewController2) conforms to this protocol.</p>
  
  <p>XCode is giving me a build error of: 'Cannot find protocol declaration for viewController1'</p>
  
  <p>I have seen various questions on this subject and I am certain it is to do with a loop error, but I just can't see it in my case...</p>
  
  <p>Code below..</p>
  
  <p><strong>viewController1.h</strong></p>
  
  <pre><code>@protocol viewController1Delegate;
  
  #import "viewController2.h"
  
  @interface viewController1 {
  
  }
  
  @end
  
  @protocol viewController1Delegate &lt;NSObject&gt;
  
  // Some methods
  
  @end
  </code></pre>
  
  <p><strong>viewController2.h</strong></p>
  
  <pre><code>#import "viewController1.h"
  
  @interface viewController2 &lt;viewController1Delegate&gt; {
  
  }
  
  @end
  </code></pre>
  
  <p>Initially, I had the import line in viewController1 above that of the protocol declaration. This was preventing the project from building at all. After searching on SO, I realised the problem and switched the two lines around. I am now getting a warning (as opposed to an error). The project builds fine and actually runs perfectly. But I still feel there must be something wrong to be given a warning.</p>
  
  <p>Now, as far as I can see, when the compiler gets to viewController1.h, the first thing it sees is the declaration of the protocol. It then imports the viewController.h file and sees this implements this protocol.</p>
  
  <p>If it were compiling them the other way around, it would look at viewController2.h first, and the first thing it would do is import viewController1.h the first line of which is the protocol declaration.</p>
  
  <p>Am I missing something?</p>