Xamarin C# binding of a Cocoapods iOS SDK using Sharpie

After my endeavor with Xamarin.Android Bindings and Xamarin Apps with IBM MobileFirst, I received an interesting requirement from my colleague Chethan. He wants Xamarin C# binding of our IBM MobileFirst Foundation Objective-C APIs. I thought this is an opportunity to try something new and accepted the challenge.

I immediately started exploring to find something called Objective Sharpie on Xamarin’s Objective-C binding page. While reading through the documentation, I found one more interesting scenario which will simplify my binding effort i.e., Effective version 3.0, Objective Sharpie supports binding CocoaPods.

Yay!! We already have IBM MobileFirst Platform Foundation iOS SDK available on Cocoapods and now it’s time to follow the steps mentioned in the documentation.

The first step is to download, setup and update objective Sharpie. Once we are all good, Our journey begins towards achieving Xamarin C# binding.

Run the below command on a terminal.

If all goes well, Here’s the expected output

Success ! There’s one more command before we see the binding,

Possible Errors & their fix:

Commands can go good and at the same time can error-out. In my case, there were a bunch of errors.

No worries! We can fix the error in multiple ways,

  1. As the issue is with unity plugin, We can uninstall unity from the Mac and install again. If that doesn’t fix the error,
  2. Navigate to ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ folder and delete the plugin if the plugin is not in use.

There’s also a chance that the Cocoapods iOS SDK expects a lower iPhoneOS SDK like the error below,

In reality, We may see SDK version higher than the one mentioned in the error description and our Xcode is up to date. To fix the error,

  • Download the version of Xcode with the SDK version you are looking for.
  • Right click on the Xcode_ .dmg file and Select “Show Package Contents” from the menu.
  • Now navigate to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ and copy iPhoneOS<Version_number>.SDK folder.
  • Paste the copied folder to

If all goes well, You should see a lengthy output on the terminal + a couple of warnings with a word Done. You should see the below binding definition files once you navigate to the base folder.

Binding output

Note: You can follow the above steps to generate Xamarin C# binding definition for any Cocoapods iOS SDK.

You can use the btouch-native for Xamarin.iOS to build bindings directly. It works by passing the C# API definitions that you’ve created using Objective Sharpie to the command line tool btouch-native for iOS.

If you see any errors, post the same as a comment below.

Happy Binding!!!

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

You may also like...

Show Buttons
Hide Buttons