【问题标题】:Objective-sharpie ApiDefinition contains overloaded methods?Objective-sharpie ApiDefinition 包含重载方法?
【发布时间】:2018-08-28 18:33:15
【问题描述】:

经过一番摸索,我终于得到了objective-sharpie,成功绑定了.framework文件,但是它生成的ApiDefinition.cs文件包含一些不规则。

    // @optional -(void)flyerView:(WFKFlyerView * _Nonnull)flyerView gotSingleTap:(id<WFKFlyerViewTapAnnotation> _Nullable)annotation atPoint:(CGPoint)point;
    [Export("flyerView:gotSingleTap:atPoint:")]
    void FlyerView(WFKFlyerView flyerView, [NullAllowed] WFKFlyerViewTapAnnotation annotation, CGPoint point);

    // @optional -(void)flyerView:(WFKFlyerView * _Nonnull)flyerView gotDoubleTap:(id<WFKFlyerViewTapAnnotation> _Nullable)annotation atPoint:(CGPoint)point;
    [Export("flyerView:gotDoubleTap:atPoint:")]
    void FlyerView(WFKFlyerView flyerView, [NullAllowed] WFKFlyerViewTapAnnotation annotation, CGPoint point);

    // @optional -(void)flyerView:(WFKFlyerView * _Nonnull)flyerView gotLongPress:(id<WFKFlyerViewTapAnnotation> _Nullable)annotation atPoint:(CGPoint)point;
    [Export("flyerView:gotLongPress:atPoint:")]
    void FlyerView(WFKFlyerView flyerView, [NullAllowed] WFKFlyerViewTapAnnotation annotation, CGPoint point);

所以这实际上不会编译,因为 Visual Studio 恰当地指出,尽管具有不同的 [Export] 属性,但这些方法具有完全相同的定义。我尝试更改它,因此只有一个具有多个 [Export] 属性的方法,但这也是不允许的。不知道在这里做什么。

顶部还有一个 using 声明,我认为它试图指向我在 Visual Studio for Mac 的 Xamarin 项目中设置的 Native Reference,但它不起作用 (type or namespace could not be found are you missing an assembly reference, etc.)

非常感谢任何帮助!

【问题讨论】:

    标签: xamarin xamarin.forms xamarin.ios objective-sharpie xamarin.ios-binding


    【解决方案1】:
    1. 通过注释掉生成代码中的重复实现(即具有相同参数的实现等)来修复警告。
    2. 删除了生成的空接口。
    3. 在 ApiDefinition.cs 中注释掉了“使用 xxx(您的 SDK 名称)” — 不确定为什么需要这样做!

    【讨论】:

    • 所以我实际上最终重命名了方法以匹配它们的导出名称:FlyerViewGotSingleTap, FlyerViewGotDoubleTap, FlyerViewGotLongPress 而不是删除 2/3。我也刚刚注释掉了你提到的 using 语句 - 谢谢!我没有意识到这是一个不必要的 using 语句,我认为它很重要。
    猜你喜欢
    • 1970-01-01
    • 2017-07-21
    • 1970-01-01
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多