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.

Picture_2.png

Change it to use the iPhone SDK.

Picture_3.png

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

Picture_5.png

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.
Picture_6.png

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.

Picture_7.png

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.