How do I create a static library for iPhone?

I think I've looked everywhere for an answer to my problem, but with no luck.

I'm trying to create a simple static lib to run on an iPhone device, but I keep ending up with Xcode saying "the file does not have the required architecture" and I've tried every build flag I found with no luck.

I have work on an emulator creating it like this:

$ gcc-4.2 -c StaticHelloWorld.c -o StaticHelloWorld.o
$ ar rcs libstatichelloworld.a StaticHelloWorld.o

But how do you build it for the device?

Regards, drisse

+2


source to share


1 answer


Inside Xcode, there is a new project template called Cocoa Touch Static Library. This template provides most of the customization needed to create a static library. Then you just need to include the various source files as well as the common header file.



For an example of iPhone static libraries, see Three20 and Core Plot Projects . Both use static libraries for the iPhone. We have some instructions on how to include the library in your application in the main Core Plot quiz.

+2


source







All Articles