4

I built universal static library with help of this template

The problem that is my library libWrapper.a has size 1.3 mb??? :0 while my source code has 130 kb.

How I can reduce the size of my static lib?

Other strange thing -

enter image description here

Each lib has the same size - 1.3 mb. I supposed that universal (fat) libs should have bigger size.

Injectios
  • 2,777
  • 1
  • 30
  • 50

3 Answers3

13

Also make sure that you set Generate Debug Symbols to NO in your build settings. This can reduce the size of your static library by about 30%.

g_low
  • 2,435
  • 19
  • 23
3

in terminal run

strip -x [youStaticlib.a]

Description

For dynamic shared libraries, the maximum level of stripping is usually
 -x (to remove all non-global symbols).

if you want to know strip other parameter, in terminal run

man strip
Ghost Clock
  • 191
  • 1
  • 2
  • 13
-2

You cant. Static libraries include all the code that they reference in the form of frameworks inside their executable.

deleted_user
  • 3,817
  • 1
  • 18
  • 27
  • because they have their linker settings to not include so much, and yes I am sure. – deleted_user Jul 30 '12 at 15:10
  • This is incorrect. Static libraries are simply an archive of .o files. They do *not* include the code from frameworks. Frameworks are dynamically linked. – idz Jul 30 '12 at 15:12
  • 1
    Thats what static libraries ARE - hence the name static. Apple does not support static linking to iOS frameworks, but if you are statically linking to 3rd party frameworks all their code will be *statically* linked into your apps executable. – deleted_user Jul 30 '12 at 15:21
  • Also static linking in general is not recommended by Apple for 3rd party or otherwise. – deleted_user Jul 30 '12 at 15:23
  • @user490696 I am curious to know where you read that static linking is not recommended by Apple? How else would people include closed source analytics libraries or even libraries that developers have written themselves? – Joe Jul 30 '12 at 18:43
  • I meant static linking to apple frameworks, you can static link to 3rd party libs, obviously. But theres nothing you can do to reduce the size of your target. – deleted_user Jul 30 '12 at 19:17
  • @user490696 You can't statically link to a dynamic library/framework. Static libraries and dynamic libraries are very different. The former is, as I mentioned before, an archive of .o files the latter is a specially formatted executable. – idz Aug 02 '12 at 05:28