mongodb/libbson — pull request #47 by paulmelnikow (2014-03-30 21:19:02+00:00)
Title: Objective-C bindings

These are some basic bindings for Objective-C. They support serialization and deserialization, and include decent test coverage.

The included Xcode project includes unit test targets for Mac OS and iOS. Under iOS, I've addressed compiler warnings, but as yet have not been able to run the tests, which requires a static library for armv7. I'm not sure how to accomplish that with the new build system.

Not addressed in this commit is any kind of packaging strategy. Since libbson doesn't ship with the OS, and apps are deployed as bundles without the help of a package manager, the app needs to ship with the library bundled inside. Most developers will prefer to build it at their app's build time, either as a static library target, or more commonly by linking the object files directly into the app binary.

[CocoaPods][] is a popular tool for dependency management in this space. It's not required for [ObjCMongoDB][] but probably most developers probably acquire it and the legacy C driver that way. This [CocoaPods package spec][spec] takes the latter approach described above: it directs Xcode to include the *.[ch] files from 'src' in the build target for whatever the developer is building.

A good goal would be to pull in the C and Objective-C code with CocoaPods. It mimics what developers can do now, and would get the supported bindings into the most hands. That said, I'm not sure the right way to accomplish this. CocoaPods has a ["prepare" command][prepare], which runs at dependency-install time, and invoke some or all of the build system. It can also specify which files or libraries need to get included down the line, can specify compiler flags, and supports Xcode prefix headers, which basically are automatic #includes.

Once we address the packaging question we can think about how to properly integrate the build system. And also the best way to generate documentation.

I figure this is a good starting point for discussion. Let me know your thoughts!

[ObjCMongoDB]: https://github.com/paulmelnikow/ObjCMongoDB
[CocoaPods]: http://cocoapods.org/
[spec]: https://github.com/CocoaPods/Specs/blob/master/mongo-c-driver/0.8.1/mongo-c-driver.podspec
[prepare]: http://guides.cocoapods.org/syntax/podspec.html#prepare_command