An Xcode 4 template to create universal static libraries

I’ve created an Xcode 4 project template to create universal (armv6, armv7 and simulator) static libraries for iOS, based on Adam Martin’s script:


The existing static library template provided with Xcode only builds one architecture, which is not particularly suitable for distribution. A number of people have created scripts to create universal libraries, which require some mucking around with Xcode target settings to use.

This template draws on this work to provide all that is required to produce universal libraries – just select the ‘Universal Static Library’ type in the New Project/New Target dialog, and you’re all set.

Universal static library

, , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. Alex
    Posted March 30, 2012 at 9:07 am | Permalink

    Hi Michael,

    Afraid it’s not working for me. I’m getting: warning: ignoring file ~/libHRVKit.a, missing required architecture i386 in file

    When trying to link against the created library. Any suggestions?


    • Posted March 30, 2012 at 10:41 am | Permalink

      Hey Alex – it sounds like you’re grabbing the lib from the wrong architecture; when you build, there’ll be three different folders showing up in the built products dir (accessible by right-clicking the product and hitting ‘Show in Finder’) – [Debug/Release]-iphoneos, -iphonesimulator, and -universal. You wanna grab the built library from the ‘universal’ folder.

      Hmm… I was gonna say I’ll update the documentation to be clearer about that, but maybe it’d be more obvious to just copy the universal build to the other folders! I’ll do that instead.

  2. Alex
    Posted March 30, 2012 at 4:40 pm | Permalink

    Ah thanks very much. I was a) being stupid, b) seemed to have made a series of compounding mistakes that got XCode in quite a twist. One quick followup question. I don’t think it’s possible, but might as well make sure. Is there any way I can bundle a resource inside the static library? Even if the library itself is the only thing that will use it, ie. it doesn’t need to be available to external projects?

    Thanks for the quick turnaround.


    • Posted March 30, 2012 at 4:43 pm | Permalink

      Cool =)

      Yeah, sure – take a look at xxd (xxd -i {infile} > {outfile.c})