Xcode: how to build a static library project correctly?

This question will be easy for Xcode pros but for a MonoTouch developer it seems to be impossible to resolve. :-)

I'm using Xcode 4.5 and I want to target iOS 5.1 and above and iOS Simulator 5.1 and above.

I have aa library project here and it is coming with a prebuilt binary named "DemoLib" (no extension and it is 11MB in size). The library is a fat lib for Simulator and iOS 5.1+. I can use that library without any problem. However if I try to build the library myself, I end up with a "DemoLib.a" file (notice the extension and the size of 30MB). How can I get the same build result? What is a .a file compared to the file without extension? I tried to build the project "for running", and "for archiving" in Xcode. Both results in the same 30MB .a file. I was expecting some dropdown in Xcode where one could select "DEBUG" or "RELEASE" build and the latter one would create the smaller lib.


Of course I could never tell without seeing the framework's project file. Having said that, there is an excellent guide to creating and compiling iOS frameworks here: https://github.com/jverkoey/iOS-Framework

Using the above guide, you should be able to recreate your framework's project from scratch, add the files you have to it, and properly compile it.

Hope this helps! :)


Did it come with a Makefile? Create a new target, set the build settings of the target to what's in the Makefile, then set your project to depend on that new target.

A file with the .a is a static library, which means it depends on nothing external and all the code it needs is compiled inside it. I think no extension generally implies dynamic library, which means it'll depend on some dependencies being present on your system to link against. Maybe that's why the .a is so much bigger. I think Xcode will build static by default because iOS does not allow the use of dynamic libraries.

The dropdown for what to build is in your scheme. Command+shift+< to view your scheme. Within the scheme you can edit which environment each method of building will use.

链接地址: http://www.djcxy.com/p/11506.html

上一篇: GHC在可能的情况下是否消除多态性间接性?

下一篇: Xcode:如何正确构建静态库项目?