Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 a a 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.

like image 753
Krumelur Avatar asked Nov 30 '12 19:11

Krumelur


People also ask

How do I create a static library in Xcode?

Open XCode and start a new project. Under iOS, select Library and “Cocoa Touch Static Library” say it as "staticlibrary". This will create a nice new project for us that builds a . a file.

How do I create a static library in Swift?

Create Static Library ProjectOpen Xcode and select Cocoa Touch Static Library . Give it a name and select Swift as the development language. In our case, we will call it Networking and assume that it will contain the code to communicate with a back end. Press Cmd+N and select Swift file .

Is XCFramework static or dynamic?

An XCFramework can be either static or dynamic and can include headers.

What is the format of a static library?

Static libraries are simply a collection of ordinary object files; conventionally, static libraries end with the ``. a'' suffix. This collection is created using the ar (archiver) program.


1 Answers

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! :)

like image 188
Tarek Avatar answered Nov 15 '22 07:11

Tarek