I would like to write some Objective-C code for distribution. What is the best way to package up the output. In Java you can package up your code in a JAR file and distribute that. What would be the equivalent in Objective-C?
The following link is close, but seems to address more of the namespace issues which I am not concerned about. I am mostly concerned about setting the code up for easy distribution.
Objective-C equivalent of Java packages?
A framework is almost certainly the way to go. One of the really nice things about Frameworks on OS X is that they can bundle the executable code, headers, metadata, images, icons, etc. in a single package. Further, frameworks can be included in */Library/Frameworks/
or even inside your app bundle to completely decouple from any other app's dependency on a given version of the framework.
Apple's Framework Programming Guide is the best place to get started with frameworks.
Creating a framework is simple. Basically, in Xcode you choose File > New Project... and select Framework, then Cocoa Framework. This will set up a new project with framework target and automatically package everything up for you when you build.
Don't forget that documentation and unit tests are a Good Thing™, especially for frameworks, which are inherently more likely to be used by multiple clients than most end-user code. You can add more targets to your framework Xcode project to document and test it.
Since you're looking for examples, check out CHDataStructures.framework (a project which I develop) and PSMTabBarControl.framework (which includes lots of extra resources in the framework). Both are open-source, and should provide adequate examples for rolling your own.
One word of advice to save you some head-scratching: your header files will not be copied to the built framework unless you click on the framework target and change the Role to "Public" (or "Private").
You want to create a Framework. There is a starting point in Xcode for a new project to create one of these. There are a few caveats and gotchas, but on the whole the process is straightforward.
Edit: For clarification: If you are planning to distribute it as FOSS; packing it up in a framework might be overkill; just distributing the source code might be a more sensible and simpler option. But if you would like to keep the source to yourself or distribute it with a collection of relevant resources, a framework might definitely be a good idea.
Reedit: For an introduction, see http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
You didn't say if it was for iPhone or not. On the iPhone, it needs to be a .sa (statically linked library) -- but I think the normal distribution would by a .dylib or .so
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With