2

This link discusses how to create iOS static framework, and they said

With static libraries, everything else (including the header files) you must distribute separately.

Actually I found no difference between using static lib and framework, you can look at the Admob SDK (https://developers.google.com/mobile-ads-sdk/docs/), what they ask is just pull all the files in the XCode project, so I really don't understand why we need to use framework over just plain static lib, or am I missing something?

Howard
  • 19,215
  • 35
  • 112
  • 184
  • You should need the `.a` file plus the `.h` files, and also any sound or image files, etc. – woz Aug 20 '12 at 16:32
  • a Framework usually combines the header files and .m files in one package, unlike a library which only has the source (.m) files, and you have to add the header files separately to your project. – KDaker Aug 20 '12 at 16:37
  • You were not allowed to include a Framework in Xcode 3 - just libraries. At some Xcode 4 started to support them. – David H Aug 20 '12 at 17:50
  • @DavidH that is wrong. Custom frameworks using dynamic libraries were always prohibited on iOS (non jailbroken). Custom frameworks using static libraries were always supported (by supported, I mean using them worked fine already on Xcode 3). – Till Aug 21 '12 at 15:57
  • @Howard we do not "need" to use them, it is mostly a convenience thing. It is just much more convenient to add a framework compared to adding a library and a bunch of headers. – Till Aug 21 '12 at 16:00
  • Have a look at this thread for more: http://stackoverflow.com/questions/8343242/objective-c-how-to-make-a-framework – Till Aug 21 '12 at 16:03
  • @Till, I remember going to a site that had all kinds of convoluted tricks to make it possible to create a framework with a static library. You even had to make an OSX version first, then modify it. Now, I see them all the time. Included project support is vastly easier in 4 than in 3. I guess in the end YMMV but my experience in 3 was not good. – David H Aug 21 '12 at 16:05

1 Answers1

6

Basically a framework is a collection of static libraries (e.g. one for i386, one for ARM) and the header files. Furthermore a framework also is a special folder with a very well defined structure.

I am not quit sure what you mean by 'just add the folder in Xcode'... If you mean adding a folder containing all the source code or a folder containing the static library including the header files you are right and there (very often) is no really big difference (depending on the library to include).

Using a framework is primarily a usability thing. Adding a framework, which means adding one single artifact, is less error prone than adding a bunch of files. For example it is not possible to accidentally omit one header file.

zlajo
  • 2,173
  • 1
  • 19
  • 25