Universal Framework

Universal Framework Project Setup

I’ve always loved backend code to be as cross platform as possible. Writing everything based upon Foundation and CoreFoundation only is one of the ways to do that and I’ve always strived to adhere to that principle as much as possible.

While that is cool, the problem begins when you actually want a universal library to work on both OS X and iOS. There is no such thing as Xcode clearly separates both. Understandably, this is seems to be an engineering and architecture decision. Still it would be cool to have a library that you can drop in either your OS X or iOS project.

There is largely 2 schools of thought.

  1. Create your own .framework directory structure
  2. lipo your own static library

There is inherently more flexibility with option 1, but the complexity of building such a framework is huge. Additionally it doesn’t allow you package everything in an Xcode project that can act as a dependency in your other projects.

Using lipo presents its own problems too as a Fat binary must contain code for unique architecture. In short, you cannot have a fat binary with code for the iPhone Simulator and OS X as both contain the same architecture.

After much experimenting I’ve figured out my own solution for this which I feel gives a much better workflow. The genius of the solution is that independently the project will build and create fat binaries for both iPhone Device + iPhone Simulator as well as iPhone Device + OS X.

Additionally, it can be added to existing projects as a dependency and build the appropriate static library which you can then use to automatically link to your project.

One thing to note though with this approach is that if you have the usage of Categories in your code, you will have to add to the Other Link Flags configuration of the Xcode build settings the “-ObjC” flag. Related Technical Q&A here.

Currently two of my projects use such a method of sharing code.

***Update: If you are using the dependency way of getting things done, just link to the “Device” build target. Every time you want to switch the build target you are working on, just do a Clean all. Xcode will build the architecture of either the simulator or the device depending on selection.

On to the steps.

Read More

To infinity and beyond

Just about a month ago prior to WWDC10, I made the decision to drop any web development and concentrate on native development for the OS X platforms which include the iPhone and the Mac.

Since then its been a whirlwind with many opportunities presenting themselves. Sadly I can’t take any offers to join companies due to issues with my Scholarship. That being said, freelancing and consulting generally works out to be alright.

Right now, I’m currently engaged in a project so I won’t be free to handle anything during these few months. Still, drop me an email if you have something that comes after that.

(I so have to update this page.)

Back to the drawing board

Working on a new project. Using stuff learnt from the initial work on Traversity. Namely the process where creation of the data model and associated libraries are done first and foremost before connecting up the GUI.

As a usual practice, the library will be open source. No sense creating something that no one else will use. Check the progress on Github.

This should be fun.