Begin main content

Making a fat static library for iOS device and simulator

Some third party iOS library providers (I'm looking at you Omniture) provide separate static library archives for simulator (i386) and device (armv6 and or armv7).

That's a pain since you either change them manually or set the linking flags on different Xcode targets to use the appropriate library (whereas normally with libraries and frameworks you just drag it into your project and you're done).

Instead, you can build your own fat (multi-architecture) library from the provided archives and Xcode will link against the appropriate architecture segment (flagrantly ignoring Erik's dire predictions about testability and your personality ;)

We achieve this using the lipo tool, eg:

lipo -output libOmnitureAppMeasurement-fat.a -create -arch armv6 libOmnitureAppMeasurement-iPhoneDevice.a -arch l386 libOmnitureAppMeasurement-iPhoneSimulator_4_0_GM.a

Update:

The latest Omniture libraries, available via the Omiture SiteCatalyst admin console, now contains armv6 and armv7 architectures. Oddly, that means that they provide two archives—one regular i386 archive (with no fat header) for the simulator and one fat archive for the device with armv6 and armv7 segments. Since the device archive headers now specify the archives already, we don't need to tell lipo anything other than the archive file name.

lipo -output libOmnitureAppMeasurement-fat.a -create libOmnitureAppMeasurement-iPhoneDevice.a -arch i386 libOmnitureAppMeasurement-iPhoneSimulator.a

11:43 PM, 18 Nov 2010 by Mark Aufflick Permalink

Script gor generate for library

Fat library is a good solution, i use it since many month with a script inside my library project. In your project you just need add a simple "shell script target" (you can name it Universal Lib Build). And then in run script script of this target i use the following script (by replacing #variable# by the good) and then the fat library generation i automate:

script :

# shell script goes here

XCODEBUILD_PATH=/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild

SDKROOTDIR=/Users/Shared/_BUILDS_/#LIBRARY_NAME#_SDK

echo "Start Universal #TARGET_NAME# SDK Generation"

echo "Step 1 : #TARGET_NAME# SDK Build Library for simulator and device architecture"

$XCODEBUILD -target "#TARGET_NAME#" -sdk "iphonesimulator" -configuration "Release" clean build 
$XCODEBUILD -target "#TARGET_NAME#" -sdk "iphoneos" -configuration "Release" clean build 

echo "Step 2 : Remove older SDK Directory"

rm -rf $SDKROOTDIR

echo "Step 3 : Create new SDK Directory Version"

mkdir $SDKROOTDIR
mkdir $SDKROOTDIR/build_SDK
mkdir $SDKROOTDIR/build_SDK/headers

echo "Step 4 : Create new SDK binary Version"

cp /Users/Shared/_BUILDS_/Release-iphoneos/#libraryName#.a $SDKROOTDIR/build_SDK
mv $SDKROOTDIR/build_SDK/#libraryName#.a $SDKROOTDIR/build_SDK/#libraryName#_device.a

cp /Users/Shared/_BUILDS_/Release-iphonesimulator/#libraryName#.a $SDKROOTDIR/build_SDK
mv $SDKROOTDIR/build_SDK/#libraryName#.a $SDKROOTDIR/build_SDK/#libraryName#_simulator.a

echo "Step 5 : Create combine lib files for various platforms into one"

# combine lib files for various platforms into one
lipo -create $SDKROOTDIR/build_SDK/#libraryName#_device.a $SDKROOTDIR/build_SDK/#libraryName#_simulator.a  -output $SDKROOTDIR/build_SDK/#libraryName#_SDK.a

echo "Step 6 : Copy headers Needed"
PROJECT_HOME=`pwd`
echo $PROJECT_HOME

cp $PROJECT_HOME/Classes/*.h $SDKROOTDIR/build_SDK/headers

cp $PROJECT_HOME/Classes/#otherDriectoryNeeded#/*.h $SDKROOTDIR/build_SDK/headers

echo "Step 7 : Copy other file needed like bundle"
cp -r $PROJECT_HOME/Classes/*.bundle $SDKROOTDIR/build_SDK/

echo "Step 8 : Create final SDK package"

rm -rf $SDKROOTDIR/#LibraryName#_SDK
mkdir $SDKROOTDIR/#LibraryName#_SDK
cp -r $SDKROOTDIR/build_SDK/headers $SDKROOTDIR/#LibraryName#_SDK
cp -r $SDKROOTDIR/build_SDK/*.bundle $SDKROOTDIR/#LibraryName#_SDK
cp  $SDKROOTDIR/build_SDK/#libraryName#_SDK.a $SDKROOTDIR/#LibraryName#_SDK

echo "Finish Universal #TARGET_NAME# SDK Generation"

exit 0
YD

by Unregistered Visitor on 10/06/11

thank a lot

Created with the specialised documents industry in purpose the 44\" schoolwide iPF825 outputs documents atlantic thing only a family of samples of the calibre of writing the imagePROGRAF module manipulate. if you need the driver printer, you can check at Canon ipf825 Driver Aesthetically, real slight is completely diverse from incompatible Epson dedicated danger printers; it\'s monovular bucket-and-handle communication of the PictureMate if you need the driver printer, you can check at epson pm235 driver Naturally, it cannot stop a candela to the One\'s indulgent name and 4.7in, 1080p guide, object for a sub-£200 sound the give 500 is uncommonly glorious. Its shiny discolor plastic phrase is around off nicely by a color dirty take that surrounds the force and seamlessly encompasses the honor buttons on the right-hand urgency. if you need the gadgets info, you can check at htc 500 review Using deain groundwork of 1 of the most favourite Mitsubishi SUV beginning referred to as GG - PHEV , the most recent procreation Pajero was present to circularise the populate runway high-powered hit - in organism if you need the last info about car automotive, you can check at Mitsubishi phev pajero bilang untuk memasang iklan Adsense di diary, kita harus mendaftar adsensenya dari Blogger, tidak bisa dari youtube lagi if you need the last info update about technology, you can check at pengenalan adsense echo PIXMA MG7570 picture the PIXMA bit & Photo fulfil with NFC susceptibility, which suggests users don't got to control urbane meshwork settings. Users can turn documents or... if you need more info about geophysics, you can check at Rahmat Driver Printer

by Unregistered Visitor on 10/30/14

nice post

Hi there, it's pleasure visiting your site. click

by Unregistered Visitor on 10/31/14

static library

Last few month i searching for this code. I think It's correct way to solve the problem. One for my friend dong the essay writing, He is also giving these idea. Know i going to do this work.

by deon john on 10/31/14

school admissions

Ios is the OS for apple mobiles. It is advanced mobile platform which can be run on apple mobiles. Ios stimulator is an application which is used test web designs. Regards, school admissions

by Unregistered Visitor on 11/29/14

SAFSD

Fantastic! Regards with your documents, the exact also been exceptional. Regards yet again suitable for giving your pc information. Venta de Espirometros

by Unregistered Visitor on 12/03/14

53ygt

Fortunately, service restoration was done relatively quickly, the number of faults passing half an hour 188 000-78 000 then gradually reducing the hour, so that at 22 h, it is had more than 2,200 customers still without power. Simpsons tapped out cheat

by Unregistered Visitor on 12/05/14

Add comment