gpt4 book ai didi

xamarin - 无法使用 Objective Sharpie 将 Objective-C 库绑定(bind)到 C#

转载 作者:行者123 更新时间:2023-12-01 13:29:21 25 4
gpt4 key购买 nike

我正在尝试浏览本指南:

https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/

尝试为这个 github 项目创建绑定(bind):

https://github.com/lminhtm/LMGaugeView

使用 Sharpie 3.4。

我遇到了以下问题:

  1. 我无法使用 i386 armv7 x86_64 arm64 架构生成 Fat 二进制文件,因为我是针对 iOS11 构建的。我只能生成架构为 x86_64arm64 的 Fat 二进制文件,尝试其他架构会给我错误消息 invalid iOS deployment version, iOS 10 is the max deployment target对于 32 位目标。这是预期的吗?

  2. 当我随后使用 Sharpie 时,我能够生成 API 和结构文件,但是,这些文件中的每一个都非常庞大,结构最终达到 24K+ 行,而 API 达到 54K+ 行。我也遵循了一个 youtube 教程,他得到的输出大约是 200 行左右,所以我的如此庞大这一事实让我觉得有些事情正在发生。他的教程不是针对我的同一个 Objective-C 项目,但我什至尝试了他所做的相同项目并最终得到了相同的结果。

  3. Struct 文件最终有超过 7K 个错误,我看到无数行类似于:

    // extern long double tanhl (long double) __attribute__((const)) __attribute__((nothrow));
    [DllImport ("__Internal")]
    [Verify (PlatformInvoke)]
    static extern [unsupported Builtin: long double] tanhl ([unsupported Builtin: long double]);

它缺少标识符名称并且有这个[不受支持的内置:我不明白的部分。

还有无数对其他 iOS 版本、watchOS 和 TV 的引用,因此它似乎正在尝试为存在的每个操作系统和版本创建 API 和结构,这就是为什么文件会如此之大的原因。这是结构文件中的一小段:

    // extern CGPathRef _Nullable CGPathCreateCopyByTransformingPath (CGPathRef _Nullable path, const CGAffineTransform * _Nullable transform) __attribute__((availability(ios, introduced=5.0))) __attribute__((cf_audited_transfer));
[iOS (5,0)]
[DllImport ("__Internal")]
[Verify (PlatformInvoke)]
[return: NullAllowed]
static extern unsafe CGPathRef* CGPathCreateCopyByTransformingPath ([NullAllowed] CGPathRef* path, [NullAllowed] CGAffineTransform* transform);

// extern CGMutablePathRef _Nullable CGPathCreateMutableCopy (CGPathRef _Nullable path) __attribute__((availability(ios, introduced=2.0))) __attribute__((cf_audited_transfer));
[iOS (2,0)]
[DllImport ("__Internal")]
[Verify (PlatformInvoke)]
[return: NullAllowed]
static extern unsafe CGMutablePathRef* CGPathCreateMutableCopy ([NullAllowed] CGPathRef* path);

// extern CGMutablePathRef _Nullable CGPathCreateMutableCopyByTransformingPath (CGPathRef _Nullable path, const CGAffineTransform * _Nullable transform) __attribute__((availability(ios, introduced=5.0))) __attribute__((cf_audited_transfer));
[iOS (5,0)]
[DllImport ("__Internal")]
[Verify (PlatformInvoke)]
[return: NullAllowed]
static extern unsafe CGMutablePathRef* CGPathCreateMutableCopyByTransformingPath ([NullAllowed] CGPathRef* path, [NullAllowed] CGAffineTransform* transform);

我知道这些文件应该小得多,尤其是因为 Objective-C 代码是单个头文件。我在这里做错了什么?

如果需要,我可以提供更多详细信息!

最佳答案

我很快检查了您提到的 LMGaugeView pod。

事实证明,为此您必须拥有最新的 XCode 和 Sharpie(当前版本为 3.4)。

您可以通过运行 sharpie update 来更新 sharpie。然后你可以生成一个绑定(bind)。

我已经尝试过了,它似乎工作得很好,看看你自己:youtube.com/watch?v=g7qQJnMxubU&feature=youtu.be

无耻插件 - 我在视频中使用的工具是我用于 Xamarin.iOS 绑定(bind)的 sharpie 的包装器 - objc-automatic .

关于xamarin - 无法使用 Objective Sharpie 将 Objective-C 库绑定(bind)到 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46821529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com