title: Using C header and implementation files in Xcode iOS project
body: <p>I'm trying to use a separate C header and implementation file in Xcode iOS/Objective-C project.<br>
  I want to use the method I implemented in main.m but I get these errors:</p>
  
  <p><img src="https://i.stack.imgur.com/tytJh.png" alt="enter image description here">
  <a href="https://i.stack.imgur.com/tytJh.png" rel="nofollow noreferrer">Full size here</a></p>
  
  <p>I've included user.h in main.m  </p>
  
  <p>Note that Target Membership is selected in user.c for HelloWorld. When I deselect this the errors are gone. But when I try to run the app, I get these errors at compile time:
  <img src="https://i.stack.imgur.com/SIYf9.png" alt="enter image description here"><br>
  <a href="https://i.stack.imgur.com/SIYf9.png" rel="nofollow noreferrer">Full size here</a></p>
  
  <p>When I implement the struct and method in main.m it compiles and runs just fine. But I don't get it why I can't use this particular code in a separate file?  </p>
  
  <p><em>Source Code:</em><br>
  <strong>user.h</strong>  </p>
  
  <pre><code>#ifndef HelloWorld_user_h
  #define HelloWorld_user_h
  
  typedef struct {
      char *name;
      int age;
      char sex;
  } User; //sizeof(User) = 16 bytes
  
  void CreateAndDisplay(User *usr, char *name, int age, char sex);
  
  #endif
  </code></pre>
  
  <p><strong>user.c</strong>  </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void CreateAndDisplay(User *usr, char *name, int age, char sex) {
      usr-&gt;name = name;
      usr-&gt;age = age;
      usr-&gt;sex = sex;
  
      printf("User address -&gt; value:\n");
      printf("Name:\t%u\t-&gt;\t%s\n", (uint)usr, *&amp;usr-&gt;name);
      printf("Age:\t%u\t-&gt;\t%i\n", (uint)&amp;usr-&gt;age, *&amp;usr-&gt;age);
      printf("Sex:\t%u\t-&gt;\t%c\n\n", (uint)&amp;usr-&gt;sex, *&amp;usr-&gt;sex);
  
      printf("User has a size of %li bytes in memory", sizeof(*usr));
  }
  </code></pre>
  
  <p><strong>main.m</strong>  </p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  #import "HelloWorldAppDelegate.h"
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #include "user.h"
  
  int main(int argc, char *argv[])
  {
      User user1;
      CreateAndDisplay(&amp;user1, "John Doe", 24, 'm');
  
      @autoreleasepool {
          return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class]));
      }
  }
  </code></pre>