Today I Learned How to Create a Xamarin iOS Binding for Objective-C Libraries - Part 4 The Actual Binding

This is the 4th and final part about incorporating an objective-c library in Xamarin.  In my case I’m binding BEMCheckBox.  In part 3 we used Sharpie to create a C# interface for the BEMCheckBox.  In this post we will show how to use that interface. Finally you can find a working example of BEMCheckBox in Xamarin iOS here.

First take the APIDefinitions.cs and Structs.cs files in a location accessible to Visual Studio.  Also take the BEMCheckBox.framework folder and move this location accessible to Visual Studio.  For me this means moving the files to my Windows computer.

[Read More]

Today I Learned How to Create a Xamarin iOS Binding for Objective-C Libraries - Part 3 Using Sharpie to Create Binding Interface

This is the 3rd part about using the BEMCheckBox, an Objective-C library, in Xamarin.  Part 1 described how to compile the BEMCheckBox library using Xcode.  Part 2 showed how to combine the multiple libraries we compiled from Part 1 into one library.  In this part I’ll describe how to use Sharpie to create the C# API interface.

Sharpie is a tool that reads the header files in the BEMCheckBox framework and extract a C# interface.  We could create the interface manually but it’s easier if we let technology do some of the work for us.  Don’t worry about this job being replaced by a robot as we will have to manually edit the file after it’s generated, at least for BEMCheckBox.  Download the sharpie tool here and read more about the sharpie here.

[Read More]

Today I Learned How to Create a Xamarin iOS Binding for Objective-C Libraries - Part 2 Combining Libraries

This is part 2 of creating a iOS Binding for the Objective-C Library BEMCheckBox.  In part 1 we compiled the Xcode project into two separate libraries.  One for iphones (ARM architecture) and one for iOS simulators (x86/x64 architecture).

In this post I’ll discuss how to combine two libraries into one that contains all the architectures.  If you fail to combine the libraries then you will get errors when you bind to Xamarin.  If you only have the iphone library then it won’t run on the simulator and vice versa.

[Read More]

Today I Learned How to Create a Xamarin iOS Binding for Objective-C Libraries - Part 1 Compiling the Objective-C Library

There is no checkbox for Xamarin Forms applications.  This is a problem because I wanted a checkbox in a application I’m working on.  A switch wasn’t going to cut it.

After a bit of research I found that Android had native checkbox.  Half my problem was solved.  I celebrated by eating a cookie.

Then I ran into a problem because iOS does not have a native checkbox control.  I found others had solved this problem by creating a iOS button and adding a checkbox image to it.  One image for checked and one for unchecked.  This works but it means I can’t easily change the colour, size, etc. of the checkbox.  Any changes would require me to create new images.  Using MS Paint or GIMP is not my strong suit.

[Read More]