Xcode - how to include c library and header file to cocoa project?

stefanB picture stefanB · Jan 19, 2010 · Viewed 44.6k times · Source

How do I add c library to Xcode Cocoa project?

Or what is the best option, I don't want to copy them into Cocoa project directory.

I have a C project called a which compiles into library a.dylib and header file a.h, the project is located in it's own directory.

I want to use this library from my objective-c application in Xcode.

How do I add the header file and library to my Xcode project?

I can drag the a.dylib into other frameworks but what do I do with a.h?

Answer

stefanB picture stefanB · Jan 19, 2010

I figured it out.

I point to location of project a deployment directory (headers) to Search Path in project settings either:

  • as Header Search Paths, if used as <a/a.h>
  • or into User Header Search Paths, if used as "a/a.h"

As for library I just drag it to Xcode project and set it to refer to library instead of copy.