views:

63

answers:

1

I am creating an SDK for a client that includes predefined view controllers. What is the recommended way to package everything (static lib, .xib(s), and .png(s)) for easy use?

SDKs that I've used (e.g. Pinch Media) do a good job of just providing a .h and .a file that expose only user accessible functionality and hiding everything else. As I read Apple's documentation, a framework would be ideal but is not permitted on iPhoneOS.

Some key requirements:

  1. Don't expose source or object internals.
  2. Be easy to use & set up.
  3. Work on both the device and simulator.

Thanks!

+1  A: 

Frameworks would be ideal, but as you said, aren't allowed on the iPhone. I think in the end you'll need to provide at least 3 files: a header file, a static library, and a resource bundle.

The header file would simply have all the API's you do want to expose. If you have multiple classes you may want to provide multiple headers.

For the static library I recommend compiling it like normal for each architecture (Device and Simulator), and then use lipo to combine them like so (replacing paths as necessary):

lipo -create -output output/file/path device/file/path simulator/file/path

With the bundle you can make a new target in Xcode to create a bundle, but really it's just a folder. You would also need to make you're SDK know how to load the bundle, and get to the resources. You can't load executable code from the bundle however; that is the reason frameworks don't work on the iPhone.

Cory Kilger
This is what I suspected. How then does one load a nib from the resource bundle? The obvious method (UIViewController's initWithNibName:bundle:) doesn't seem to work.
twhipple
To answer my own question in the comment above, the key seems to be to create the NSBundle object using the path (not identifier) and pass it to initWithNibName:Bundle:.
twhipple