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

Edu

Institutes ought to keep in view the monetary conditions from the learners. They should be hard college essay writing service grab essays throughout using high priced expenses or perhaps school fee.

by Unregistered Visitor on 02/18/15

Nice

This is my first time go to see at here and i am genuinely pleasant to read everything at one place. Reality Porn Tube

by Denell Eposey on 02/18/15

ragahv

An appropriate completely did watch acted this kernel besides essence of the sire. We pick finally hardly neglect this friendly of stroke regarding kindness. cccam server

by Unregistered Visitor on 02/19/15

good job

choose the best holi images, sms, wallpapers from our beautiful collection and share with friends on whatapp, facebook,twiiter and other social media holi whatsapp messages

by koppadi nani on 02/25/15

website

Help Making Mobile Phone Apps Here It looks like I am raking in money now, but the truth is that it was not always like that! Just 6 months ago I was completely struggling. I had no programming skills, no team and no money. The only thing I had was a great desire to create the game of my dreams. http://03dd4gqsm6tr0yebio1bnhhsxg.hop.clickbank.net/?tid=PHXDAN ...

by Unregistered Visitor on 02/26/15

wdw

Emulatore xBox 360La corte ha sentito diversi partecipanti frode Kippax piramidale. Questi dovrebbero "investire" tra $ 3200 e $ 3600 e le loro ricompense monetarie sono stati promessi se hanno reclutato altri investitori. xBox 360 Emulatore

by Unregistered Visitor on 02/26/15

buy cheap youtube subscribers

Want to enhance Real YouTube subscribers? Here you can buy YouTube Likes, subscribers, views or Comments with quality and best service at cheap price.visit here Visit here

by Unregistered Visitor on 03/05/15

mahi

An person hint eerie visceral the internet browser the go amid crucial hatch in fact you might conquest struck of surprising to help calm explicit. Inside my amateur bacons, I phase goodye to accessory create-up quagmires. I sentry narrative the cost-maintain. Attendance Software dubai

by Unregistered Visitor on 03/08/15

SDAFSDF

Fantastic details. Alternatively although individual combined with every individual have the ability to undertaking furthermore approach further up over time additional drastically paying for considering often kinds web site combined with We have been persuaded! Gratifying critical know-how this is actually the exceptional factor: ) Vibrating Vaginas

by Unregistered Visitor on 03/09/15

essayfast.net

I have seen quite a few people asking about essayfast.net. I think it would be better to look for reviews in order to know what they have to offer in terms of quality and the duration for this. Could you give a few pointers on how to identify genuine reviews?

by Unregistered Visitor on 03/09/15

abbycristal

Hi all, here every person is sharing these experience, therefore it’s fastidious to read this blog, and I used to visit this web site all the time. applusautointernational |

by Unregistered Visitor on 03/11/15

abbycristal

Army Center of Military History presents an online book, including tables, charts, maps, and illustrations, detailing the battle of . strategies to end the Pacific war, addressing the role signals intelligence played in military planning. It includes intelligence estimates from 1945 of Japanese troop strength and other important factors. grobautomation |

by Unregistered Visitor on 03/11/15

I like the way you described the topic with such clarity.

I like the way you described the topic with such clarity. Thanks for Describing Everything. www.edtechhackathon.com |

by Unregistered Visitor on 03/11/15

It is really a nice and useful piece of information.

It is really a nice and useful piece of information. I am glad that you shared this helpful information with us. Please stay us up to date like this. Thank you for sharing. www.numinustech.com |

by Unregistered Visitor on 03/11/15

Liputan6.com

Baca Berita Batu Akik terbaru Liputan6 Baca Berita Model Rambut terbaru Liputan6 Baca Berita Resep Masakan terbaru Liputan6 Baca Berita Foto Lucu terbaru Liputan6 Baca Berita Fakta Unik terbaru Liputan6 Baca Berita Cerita lucu terbaru Liputan6 Baca Berita Berita Teknologi terbaru Liputan6 Baca Berita Aplikasi Android terbaru Liputan6 Baca Berita Game Seru terbaru Liputan6 Baca Berita Berita otomotif terbaru Liputan6 Baca Berita Modifikasi Motor terbaru Liputan6 Baca Berita Mobil Murah terbaru Liputan6 Baca Berita Sosial Media terbaru Liputan6 Baca Berita Komunitas terbaru Liputan6 Baca Berita Blog Keren terbaru Liputan6

by Unregistered Visitor on 03/19/15

abbibarclay

Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work okhomewindows.com |

by Unregistered Visitor on 03/23/15

abbibarclay

Hello, i am glad to read the whole content of this blog and am very excited and happy to say that the webmaster has done a very good job here to put all the information content and information at one place. auditmyhometoday.com |

by Unregistered Visitor on 03/23/15

rockdd

The wife or husband along with most of us critically treasured your personal special distribute. As i hindrance day-to-day with all the current several difficulties for the purpose of consideration. Good, i will verify your personal special testimonials in addition to imagine it will help. Free Picks Tips

by Unregistered Visitor on 03/24/15

berita terkini

berita terbaru berita terbaru terkini indonesia Liputan6.com
berita internasional berita internasional terkini indonesia Liputan6.com
politik politik terkini indonesia Liputan6.com
peluang usaha peluang usaha terkini indonesia Liputan6.com
berita saham terkini berita saham terkini terkini indonesia Liputan6.com
berita ekonomi dunia terupdate berita ekonomi dunia terupdate terkini indonesia Liputan6.com
berita artis terkini berita artis terkini terkini indonesia Liputan6.com
info film box office info film box office terkini indonesia Liputan6.com
musik musik terkini indonesia Liputan6.com
bola bola terkini indonesia Liputan6.com
jadwal bola jadwal bola terkini indonesia Liputan6.com
liga inggris liga inggris terkini indonesia Liputan6.com
gaya hidup sehat gaya hidup sehat terkini indonesia Liputan6.com
diet diet terkini indonesia Liputan6.com
seks sehat seks sehat terkini indonesia Liputan6.com
bintang bintang terkini indonesia Bintang.com
vidio vidio terkini indonesia Vidio.com

by Unregistered Visitor on 03/25/15

uali20

You need to take part in a contest for one of the finest websites online. I'm going to recommend this web site! soundcloud plays soundcloud likes

by Unregistered Visitor on 03/25/15

rock

I recently these days at the moment couldn’t log off your internet site ahead of assisting you in order to to uncover which often many people severely once-in-a-lifetime the biggest excellent files everyone learn any readers? Excellent, i most certainly will a complete brand new commonly to consider brand-new specifics. act test prep

by Unregistered Visitor on 03/27/15

uali20

Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. buy soundcloud views buy soundcloud reposts cheap

by Unregistered Visitor on 03/28/15

Add comment