9.6 Creating Frameworks

A shared library can be packaged, along with its associated resources, as a framework. To create a framework, you must build and install a shared library in a framework directory. As an example, let's package the libanswer.dylib shared library as a versioned framework, using the name ans . That is, the framework will be a directory named ans.framework , which will contain the shared library file named ans . Three basic steps are required to build a versioned framework:

  1. Create the framework directory hierarchy. If this is the first version of the framework on the system, the bottom level directory will be A . This is where the shared library will be installed. If you subsequently install a later version of the shared library it will be installed in a directory B at the same level of the directory hierarchy as A .

     mkdir -p ans.framework/Versions/A 
  2. Build the shared library in the framework Versions directory.

     cc -dynamiclib -o ans.framework/Versions/A/ans answer.o 
  3. Create symbolic links. For the first installation of the shared library (i.e., in A ), Current points to A . When a later version of the library is subsequently installed in B , the Current symbolic link will be changed to point to B . The older version in A can stay on the system in case an application needs the older version. Since the symbolic link ans.framework/ans also points the most recent version of the shared library, it will also need to be updated when the framework is updated.

     ln -s ans.framework/Versions/A  ans.framework/Versions/Current ln -s ans.framework/Versions/A/ans  ans.framework/ans 

Mac OS X Panther for Unix Geeks
Mac OS X Panther for Unix Geeks
ISBN: 0596006071
EAN: 2147483647
Year: 2003
Pages: 212

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net