views:

55

answers:

2

What's the best practice to include existing C Libraries into an iPhone Project? I searched the Internet and actually found some pieces but nothing that explains the exact way to do it.

I'm trying to include the following Citrix XenServer SDK Library.

Any help is appreciated. Thanks!

+1  A: 

The way I did it was to just create an iPhone static library project in Xcode and drop all the library's files in there. Then check if it builds and if the build settings are appropriate for the library you wish to compile. To add the newly-created library to your binary, you should follow the steps explained in the bottom part of the Three20 readme.

Note that you can only add static libraries to iPhone projects if you wish to get them into the App Store. Xcode also doesn't provide means to create dynamic iPhone libraries.

MrMage
thanks, sounds great! trying it now :)
Henrik P. Hessel
+1  A: 

You could try to build a static library and link against that.
I didn't try that myself yet, but as far as I could see, libxenserver has libxml2 as its only dependency.
libxml2 is available on the iPhone so you might have a chance.
To get started, create a Cocoa touch static library project and drag the C files into the project.
Now you have to figure out where to place the include files.
This might get a bit tricky and you will start with a lot of compile errors, but to me it seems possible to get it compiled.

weichsel
yep, libxml2 should be included in MacOS X.
Henrik P. Hessel
works! thanks. Really hard to choose which to accept, but you checked the dependencies! :) build successful
Henrik P. Hessel