Creating a C++ Framework in Xcode 2.5
This “how to” will step you through creating a C++ Framework from an existing library on Mac OS X Tiger (10.4) using Xcode 2.5. For an in depth discussion of Mac OS X Frameworks see ADC‘s Introduction to Framework Programming Guide. Note this guide is a based on ADC’s Building a Universal Binary Framework from Open Source, which is an excellent document, however it does not discuss the necessary steps required to include header files into the built framework. It wasn’t entirely straight forward how to do this when I tried for the first time, and other’s have been similarly confused. My how to seeks to rectify this omission.
-
Create a Carbon Project

The first step in creating your C++ framework is launching Xcode and going to File -> New Project…. In the New Project window scroll down to Framework and select Carbon Framework. Click Next and name the project whatever you’d like.
-
Delete Unnecessary Carbon File and Framework

The “Carbon Framework” project template includes the Carbon.framework and a main.c file. Since the objective here to to create a framework from an existing library (say a Unix-like library or a Windows DLL), the assumption is you won’t need to link against the Carbon framework nor is a main.c file necessary. Therefore, please delete (the reference) to Carbon.framework and delete (the reference and file) main.c. The cleaned up project should look like so:

-
Add Existing Files

Now add the existing source code files to your project. Once you’ve added the external source code, your project should look something like this:

-
Set Project Roles

A “role” defines the behaviour of header files in your project. For a description of roles see the Xcode User Guide. In short, if you want specific header files to be bundled into the built framework, the role of these header files must be set to “Public”. The screen shot above is the default role assignments of header files in your project. From the drop down menu, change the roles of the header files you want included in the framework from “Project” to “Public”. Once you’ve done this, your project should look something like this:

-
Build the Framework
Build your C++ framework. The built framework will now include the public header files.