Xamarin.iOS Binding for an Existing iOS Library with Objective Sharpie

These days a new phase has crept into my developer life and I call it “generating Xamarin.iOS binding for Objective-C libraries”. After tasting success by generating Xamarin C# binding of a Cocoapods iOS SDK using Objective Sharpie, a new request hoped-in from the MobileFirst Platform Foundation team.

This time,the task is to generate Xamarin.iOS binding for Bluemix Push Notification Service Client SDK-Push Notification and engagement services that you will love. As I am well versed with binding creation, I thought it would be a cakewalk. Following the same steps as mentioned in the blog post, I ended up generating a definition binding for
IBMMobileFirstPlatformFoundation (Dependent class) against IBMMobileFirstPlatformFoundationPush.

After a bit of research, here’s how we achieved our goal.

Just a quick note before we start: Objective Sharpie is a command line tool to help bootstrap the first pass of a binding. It works by parsing the header files of a native library to map the public API into the binding definition (a process that is otherwise done manually). Objective Sharpie does not create a binding by itself, but it can help get you started!

Step 1:

Install and Setup Objective Sharpie. Download here.

Tip: Use the sharpie Update command to Update to the Latest Version.

For any assistance, while using Objective Sharpie, use sharpie -help which shows you all the commands and options available.

Step 2:

Open Terminal and run the below command:

Step 3:

For this step, we need a static library with all the required.h and.m files. If you don’t have one, follow the instructions here to create.

With an assumption that all the required header files (.h) including the Main Header file (in our case IBMMobileFirstPlatformFoundationPush.h) are sitting in the same folder, Run the below command on Terminal with appropriate output, namespace, SDK information based on your expected output.

Note: In my case, I can use iOS 9.2 or iOS 9.3 As a parameter for –sdk. Please use the appropriate SDK version based on the output.

You should see the below files under the folder where you are running all the above commands.

Definition Files for IBMMobileFirstPlatformFoundationPush

Polyglot & Pragmatic Programmer • Developer Advocate, IBM • Microsoft MVP • Intel software Innovator • DZone MVB
(Visited 9 times, 1 visits today)

Tagged as: , , ,

Author: Vidyasagar Machupalli

Polyglot & Pragmatic Programmer • Developer Advocate, IBM • Microsoft MVP • Intel software Innovator • DZone MVB