Sharpie 绑定objective-c @protocols 问题 [英] Sharpie binding objective-c @protocols issue
问题描述
我正在使用 sharpie
bind
命令为 xamarin
获取我的 iOS
库的 API 接口>
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
@protocol
绑定有问题:
The type or namespace name `IProfileDelegate' could not be found. Are you missing an assembly reference?
这是它的生成方式:
interface XLibrary : IProfileDelegate
{
[Wrap ("WeakProfileDelegate")]
[NullAllowed]
MB_ProfileDelegate ProfileDelegate { get; set; }
我知道它会创建空的 ProfileDelegate
然后编译器或其他东西用方法填充它,但我的问题是找不到 IProfileDelegate
.
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
这里 I
符号的区别(我猜是为@protocols 保留的).如何让 sharpie
生成正确的 api 定义?
Difference here in I
symbol (which is reserved for @protocols I guess).
How to make sharpie
generate proper api definitions?
我能够删除所有 I
前缀并且它编译成功,但我宁愿修复它而不是每次我需要更新源库时都重复这个.
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.
谢谢
推荐答案
请记住,所有 obj-c 协议都充当接口或抽象类,我建议将协议、模型和设置基类型设置为 nsobject,另一件事全部作为必需"的方法或属性,您需要将其指定为 Abstract
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
这篇关于Sharpie 绑定objective-c @protocols 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!