Universal Binaries are a wonderful thing, and not just if you are still writing Mac Power PC code, they are just as useful in the iOS development world.
If you do any amount of iOS development, chances are you have used (in one way or another) a static library.
Usually when you use a static library you get (or compile) 2 versions.
One for the device, and one for the simulator.
This is fine until you want to add the library to your app.
If you are using the simulator and the device for testing you have to play a swapping game with the corresponding library version.
Wouldn’t it be easier if you could just have 1 version of the library and it worked on the device or the simulator without you having to make any changes?
Sounds nice? I would say so, and luckily it is pretty easy.
The first thing you need to do is open a Terminal window (don’t worry, its just 1 command)
Use the following command (replacing the library path and name, with your libraries information):
lipo -output <StaticLibraryUniversal>.a -create <StaticLibraryDevice>.a -arch i386 <StaticLibrarySimulator>.a
Thats it!
Just use the new static library file in your project and you can move between the device and the simulator without worry about anything!
Have fun.
