xamarinobjective-sharpie

Sharpie binding objective-c @protocols issue


I'm using sharpie bind command to get API interfaces for my iOS library for xamarin

sharpie bind --namespace=XXX --sdk=iphoneos9.2 Headers/*.h

Have issues with @protocol bindings:

The type or namespace name `IProfileDelegate' could not be found. Are you missing an assembly reference?

This is how it's generated:

    interface XLibrary : IProfileDelegate
    {
    [Wrap ("WeakProfileDelegate")]
    [NullAllowed]
    MB_ProfileDelegate ProfileDelegate { get; set; }

I understand that it creates empty ProfileDelegate then compiler or something fills it with methods BUT my issue is that IProfileDelegate not found.

@protocol ProfileDelegate <NSObject>
@required
- (void)GetProfileFinished:(NSString*)_data;
- (void)SetProfileFinished:(NSString*)_data;
@end

Difference here in I symbol (which is reserved for @protocols I guess). How to make sharpie generate proper api definitions?

I'm able to remove all I prefixes and it compiles successfully but I'd rather fix it not to repeat this every time I need to update source library.

Thanks


Solution

  • Remember that all the obj-c protocol act as a interface or abstract class i recommend to put "protocol, model and set base type as nsobject, another thing all the methods or properties maked as a "required" you need to specify it as Abstract

    [Protocol, Model]
    [BaseType (typeof(NSObject))]
    interface myAwesomeDelegate
    {
      [Abstract]
      [Export(...)]
      void myRequiredMethod(uint param1)
    
      [Export(...)]
      void anotherMethod()
    }
    

    hope this will help you to fix your issue