Taranfx
Taranfx

Reputation: 10447

Linking C libraries in Xcode iOS

I built C code separately and have libperson.a output. I want to include this library into my xcode project. Added this .a under “Link Binary with Libraries” to my project.

#import "person.h"

It can't find the person.h. What am I doing wrong?

Upvotes: 1

Views: 807

Answers (1)

meaning-matters
meaning-matters

Reputation: 22966

You also need to add the header file(s) to you project. Or, if the headers are better off somewhere else, you need to add a Header Search Path to your Xcode target's Build Settings; in that way Xcode can find them.

Coming from Java: C has header files in which you typically declare public interfaces of a matching source file. Where in Java you have import after which the compiler sorts it all out for you from the binaries, in C you need to #include the public definitions as header at the source file level.

Upvotes: 2

Related Questions