Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Zebra Scanner SDK for iOS

HoomanYazdiHoomanYazdi USMember ✭✭


I am creating a binding project for Zebra Scanner SDK. The binding project compiles with no error but when I create an instance of it in my project, it's null. Any idea why??????????????

Here is the SDK Help link.

Here is the code


#import <Foundation/Foundation.h>
#import "ISbtSdkApi.h"

@interface SbtSdkFactory : NSObject




    [BaseType (typeof(NSObject))]
    interface SbtSdkFactory
        // +(id<ISbtSdkApi>)createSbtSdkApiInstance;
        [Export ("createSbtSdkApiInstance")]
        ISbtSdkApi CreateSbtSdkApiInstance { get; }
        //ISbtSdkApi CreateSbtSdkApiInstance();


var myApi = SbtSdkFactory.CreateSbtSdkApiInstance;

The problem is myApi is null after running above code. Any idea where the problem is?


  • HoomanYazdiHoomanYazdi USMember ✭✭

    I have attached the SDK Binding Project here.

  • joehannajoehanna AUBeta ✭✭

    Hi @HoomanYazdi

    Did you ever get this resolved? I am having the same problem now. Any help would be appreciated.


  • RidhwanRRidhwanR GBMember ✭✭

    @joehanna @HoomanYazdi Did you guys figure this out?

  • lalitbokdelalitbokde USMember ✭✭

    Hello Hooman , Have you solved this null issue? if yes will you please help what you changed in ApiDefinition.

  • joehannajoehanna AUBeta ✭✭

    I never got this to work. I lost the contract - but I have another one coming up and really need to get this going.

    @JohnMiller Can you help with this? Is it maybe something @redth can help with too?

  • valdeterovaldetero USInsider, University ✭✭

    I'm in the process of doing this now. I have it mostly done, but am not 100% happy with it. @joehanna are you still working on it?

  • valdeterovaldetero USInsider, University ✭✭

    @HoomanYazdi I don't think you should have the [Abstract] attribute on it.

  • valdeterovaldetero USInsider, University ✭✭

    Anyone else that comes here, check out the binding that I have on github: Suggestions or recommendations are welcomed.

  • valdetero - I am looking at the same thing, same time - what a coincidence! I had a look at your GitHub and it looks very similar to what I extracted for myself. A couple of questions - how do you actually make a call to a binding library - for instance to just get a version? Second question is why you have a delegate interface empty? Sharpie created one which seemed to have some definitions...
    HoomanYazdi - were you eventually successful with making calls to the Sdk?

  • StephenHewisonStephenHewison USMember ✭✭

    I've made some progress with this by following these steps:

    Add the objective sharpie code to the binding project and build.

    Find the generated *.g.cs files in the build output directory. Add these files to the binding project and rename to *.cs.

    Empty the ApiDefinitions file. Create a new file called Enums.cs and move the Structs and Enums to this file, then empty the original file.

    Refactor the Messaging class to be ZebraMessaging.

    Modify the CreateSbtSdkApiInstance method of the SbtSdkFactory to create an instance of ISbtSdkApiWrapper but return the type of the IISbtSdkApi interface.

    Then in your app project use the IISbtSdkApi interface.

  • valdeterovaldetero USInsider, University ✭✭

    @hobbitenok2010 You just add a reference to the binding library and new up an instance. I did this:
    public static ISbtSdkApi Instance => instance ?? (instance = SbtSdkFactory.CreateInstance());

    I assume you are referring to the two empty interface declarations at the bottom (ISbtSdkApi & ISbtSdkApiDelegate)? That's because the compiler won't let me use that type for a return type unless it exists. However, it will exist once the binding library generates it. So I create a stub to please the compiler and then it generates a type with the same name.

Sign In or Register to comment.