README-static-library-build.rtf 2.9 KB
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430
{\fonttbl\f0\fswiss\fcharset0 ArialMT;}
{\colortbl;\red255\green255\blue255;}
\vieww11000\viewh18640\viewkind0
\deftab720
\pard\pardeftab720\ql\qnatural

\f0\fs26 \cf0 (preliminary instructions from Henri Asseily, March 19, 2009)\
\
My goal was to build a completely universal, drag-and-drop framework\
for distribution. Build it in one-click, zip it, post it on the site,\
and let people download and drop in their project irrespective of what\
target or build they're doing.\
\
That said, it is known that the iPhone does not support standard\
dynamic frameworks, nor does XCode allow for creating framework\
targets for an iPhone project. So this had to be a "hack" in some\
respects. Given that, my strategy was not to achieve the above using\
XCode best practices, since I was already breaking them before even\
starting. So I elected to go the exact opposite route: the simplest,\
most independent technique to achieve the goal above. No referencing\
multiple other targets, no nothing. One target, one click, done.\
\
So it was clear that the only way to do it would be a good old shell\
script target that would do everything through CLI commands. But\
first, I had to put inside the project an empty skeletion of a\
framework, which is called the "Canonical.framework". All it has is\
the directory structure within a framework bundle. That would take\
care of simulating a framework target for the iPhone.\
\
On to the script:\
- it first cleans old output files\
- it determines the version number from svn if it can\
- then it untars the canonical framework into the build directory.\
This will be the final resting place of the build, by default "build/\
MapView.framework"\
- then it calls xcodebuild to build the MapView.a static lib for every\
single standard permutation of target and build: simulator+iphone, for\
debug+release. That's 4 builds.\
- after that, it merges the 4 libs into 2 fat libs using lipo. The\
debug lib is named with a "_debug" postfix.\
- and finally, it finishes "building" the framework:\
\'a0 \'a0 \'a0 \'a0\'95 it copies the lib over into the framework directory\
\'a0 \'a0 \'a0 \'a0\'95 it creates the correct symlinks inside the framework directory\
\'a0 \'a0 \'a0 \'a0\'95 it updates the default Info.plist with the version value calculated earlier\
\
That's it. You now have a complete, as minimalistic as possible,\
static framework that works in debug or release mode for simulator or\
device, that can be simply dropped in a project and referenced with\
#include <MapView/...h>\
\
The things to note are:\
\
- this target does not care what active build you've got, it builds\
all 4 builds irrespectively.\
- this target is independent from any other target you create, and as\
such all output products from your other targets will stay red on\
XCode if you haven't built them.\
- this target will not use your Info.plist except for the Bundle\
Version.\
\
Enjoy.\
}