I am pleased to announce a new public release of Objective Sharpie, the tool we use at Xamarin to produce C# bindings of Objective-C libraries for Mac and iOS!
Since the last public release, Objective Sharpie has matured very nicely. We have been evolving and using the tool internally at Xamarin for over a year. This year, APIs introduced in iOS 8 and Mac OS X 10.10 were bootstrapped entirely with Objective Sharpie, which was a huge milestone.
We have scrapped the GUI wizard that previously sat on top of the core in favor of a command line tool. Objective Sharpie is a very advanced tool that requires advanced knowledge of Objective-C and C, how to use the clang compiler on the command line, and generally how native libraries are put together. Because of this high bar, we felt that having a GUI wizard set the wrong expectations.
Objective Sharpie comes with one major rule for proper usage: you must absolutely pass it the correct clang compiler command line arguments in order to ensure proper parsing. This is because the Objective Sharpie parsing phase is simply a tool implemented against the clang libtooling API.
This means that Objective Sharpie has the full power of clang (the C/Objective-C/C++ compiler that actually compiles the native library you would bind) and all of its internal knowledge of the header files for binding. Instead of translating the AST to object code, Objective Sharpie translates the AST to a C# binding "scaffold" suitable for input to the
btouch Xamarin binding tools. So if Objective Sharpie errors out during parsing, it means that clang errored out during its parsing phase trying to construct the AST, and you need to figure out why.
Unfortunately that's not always an easy task. My quick advice is to always build the native library you are trying to bind, and then build a simple native program against that native library. The compiler flags you use to build the simple native program are what (in some form) you need to pass to Objective Sharpie. Often you can simply run
xcodebuild and discern what's required. However, this is a manual process, and one that does require a bit of familiarity with compiling native code on the command line.
In the coming weeks and months we will be exploring ways of improving how we can discern these command line arguments for you, but no two projects are alike. We have some good ideas that should help with a large number of public open source projects and some proprietary projects.
I've spent the last few weeks polishing Objective Sharpie up from its life over the last year as a strictly-internal tool to something that public users can consume, and I hope it is truly useful.
While Objective Sharpie is not a supported Xamarin product we are eager to collect your feedback on it! To help us collect actionable information about areas we need to improve, Objective Sharpie by default submits usage data back to Xamarin for analysis (using Xamarin Insights of course). While you can opt-out of this process, we encourage you not to do so in order to help evolve the tool. Note that we do not submit any source code or other files - just the command line arguments that you pass to Objective Sharpie and some environment and build information.
We have updated the documentation on Objective Sharpie and will continue to do so as the tool evolves. We are committed to making more frequent public releases as well now that we are satisfied with the maturity of the tool internally.