I am pleased to announce a new tool from Xamarin: Objective Sharpie, a very powerful binding definition generator for third party Objective C libraries to help provide APIs matching the .NET idioms and ensure delightful APIs.
Objective Sharpie takes much of the manual work of translating Objective C APIs into binding definitions that are consumed by Xamarin’s binding tools. Download your third party library, point Objective Sharpie to its header files, and off you go.
It does this using Clang and the SDKs installed in Xcode to extract all the API metadata needed to produce a binding: selector names, argument and return types, enums, and so on.
The only prescribed work is to transform public C# names to conform more to the Framework Design Guidelines (though this is optional, it’s highly recommended to produce an API that is a joy to consume).
Visit the Objective Sharpie documentation to learn more and download the tool for use today.
In the future we expect to integrate Objective Sharpie directly into Xamarin Studio as part of the binding project workflow. For now though, it’s quite useful enough that we wanted to release it as a standalone tool.
A Little Backstory
When I first started working to bring new APIs introduced in OS X Lion and Mountain Lion to Xamarin.Mac, it took a while to sink in the daunting and tedious task was laid before me. Lion in particular introduced hundreds, actually, thousands of new APIs – many of which were ported from iOS to Mac OS X.
This fear of monotony fueled me to implement a tool that used Clang as a library to gain access to every single detail of the source tree as it’s parsed. With this information, I was able to start generating C# code that represented a verifiably correct binding.
It’s important to note that we build Xamarin.Mac and Xamarin.iOS using the exact same binding tools that are available in Xamarin Studio to bind third party libraries. And now Objective Sharpie is no different: it helps us deliver faster on new APIs and ensure that they are accurate and error-free by producing a correct binding definition up front.
While there’s always more work to do, and the full Objective C language isn’t covered, most of the common parts are. It should today be a very valuable tool for getting a binding going in the right direction… with much less typing and much more copy and paste.
If you find something missing or incorrect, please let us know!