Stranger In A Strange Land – Binding Objective-C Libraries To Xamarin

Stranger In A Strange Land – Binding Objective-C Libraries To Xamarin

You’re almost done with your Xamarin application, and then the client does it… they request a whiz-bang feature that you don’t have time to add.  So to Github you go, trying to find that perfect open source feature that does what you need.  Oh no, another problem!  You found the perfect component, but it’s written in Objective-C and there’s no Xamarin binding available for it.  Ugh, you look at the source code – all of those colons, carets & what the heck is up with those function names? It looks like a foreign language – like ancient Latin, or a dialect only spoken in northern Wisconsin!  You look around and you feel like a stranger, in a strange land that you just don’t understand (like if you were in northern Wisconsin)!  What to do? Do not despair!  We’re going to take a tour through the Land of the Bindings, figuring out how to map an Objective-C library to C#, and by the end you’re going to feel like a local returning home. Preparing For Our Journey Before we head out, we’re going to need to figure out how to get to our destination… and our vehicle for this trip will be a Binding Project.  An iOS Binding project produces a DLL, and it’s that DLL we’ll add to our app’s project to provide the functionality written and compiled in Objective-C, but consumed in C#! Fire up Xamarin Studio, create a new solution, and you’ll find the iOS Binding Project under the C# -> iOS -> Unified API node.  Note that Xamarin Studio on the Mac must be used to create...