Tutorial: Creating a dynamic library for the iPhone

First make sure you have enabled XCode to build iPhone dynamic libraries.

Create the project using the Mac OS X Cocoa Dynamic Library template.


Change it to use the iPhone SDK.


Add an a new class because we can't test building with out one.


Delete all of the frameworks and add in the iPhone ones you need. Right click the External frameworks group icon and choose add exisiting frameworks. Then browse to: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/Frameworks/Foundation.framework/

An easy way to do this is to open an exising iPhone project then right click one of the frameworks and choose reveal in Finder. Then drag them from finder into the left pane of the Xcode project under the Frameworks group icon.

Edit the pre compiled header file to work for the iPhone frameworks. You could also add in the UIKit import if your library is going to use UI classes.


As you can see in the above picture it says Succeeded in the bottom right corner, which means building worked. The output file is called SampleLibrary.dylib.