12.8. The Dynamic Linker dyld: Prebinding, the Pre-Tiger Way

 < Day Day Up > 

12.7. 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 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 is installed in 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 is changed to point to B. The older version in A can stay on the system in case some application needs the older version. Since the symbolic link ans.framework/ans also points the most recent version of the shared library, it also needs 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

     < Day Day Up > 

    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

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