Sharpie 绑定objective-c @protocols 问题

Inj*_*ios 6 xamarin objective-sharpie

我正在使用sharpie bind命令为我的iOS库获取 API 接口xamarin

sharpie bind --namespace=XXX --sdk=iphoneos9.2 Headers/*.h
Run Code Online (Sandbox Code Playgroud)

@protocol绑定有问题:

The type or namespace name `IProfileDelegate' could not be found. Are you missing an assembly reference?
Run Code Online (Sandbox Code Playgroud)

这是它的生成方式:

    interface XLibrary : IProfileDelegate
    {
    [Wrap ("WeakProfileDelegate")]
    [NullAllowed]
    MB_ProfileDelegate ProfileDelegate { get; set; }
Run Code Online (Sandbox Code Playgroud)

我知道它会创建空ProfileDelegate然后编译器或用方法填充它,但我的问题是IProfileDelegate没有找到。

@protocol ProfileDelegate <NSObject>
@required
- (void)GetProfileFinished:(NSString*)_data;
- (void)SetProfileFinished:(NSString*)_data;
@end
Run Code Online (Sandbox Code Playgroud)

I符号的区别(我猜是为@protocols 保留的)。如何sharpie生成正确的 api 定义?

我能够删除所有I前缀并成功编译,但我宁愿修复它,以免每次需要更新源库时都重复此操作。

谢谢

小智 5

请记住,所有 obj-c 协议都充当接口或抽象类,我建议将“协议、模型和基本类型设置为 nsobject,将所有方法或属性设为“必需”的另一件事是您需要将其指定为抽象

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

  [Export(...)]
  void anotherMethod()
}
Run Code Online (Sandbox Code Playgroud)

希望这将帮助您解决您的问题