作者:mobiledu2502862117 | 来源:互联网 | 2023-02-03 21:43
我目前正在为EDQueue库创建ios绑定.
该Structs.cs
文件看起来像这样:
using System;
using ObjCRuntime;
namespace EDQueue
{
// => Enums attributed with[NativeAttribute] must have an underlying type of `long` or `ulong`
[Native]
public enum EDQueueResult : long
{
Success = 0,
Fail,
Critical
}
}
该ApiDefinition.cs
文件类似于:
using System;
using Foundation;
using ObjCRuntime;
namespace EDQueue
{
// typedef void (^EDQueueCompletionBlock)(EDQueueResult);
delegate void EDQueueCompletionBlock(EDQueueResult result);
// ETC....
// @protocol EDQueueDelegate
[Protocol, Model]
[BaseType(typeof(NSObject))]
interface EDQueueDelegate
{
// @optional -(EDQueueResult)queue:(EDQueue *)queue processJob:(NSDictionary *)job;
[Export("queue:processJob:")]
EDQueueResult Queue(EDQueue queue, NSDictionary job);
//// @optional -(void)queue:(EDQueue *)queue processJob:(NSDictionary *)job completion:(EDQueueCompletionBlock)block;
//[Export("queue:processJob:completion:")]
//void Queue(EDQueue queue, NSDictionary job, EDQueueCompletionBlock completeBlock);
}
// ETC...
}
如上所述,产生以下错误:
错误CS0426:文件类型'EDQueue'(CS0426)(EDQueue)中不存在类型名称'EDQueueResult'EDQueueDelegate.g.cs
抛出错误时,该文件如下所示:
//
// Auto-generated from generator.cs, do not edit
//
// We keep references to objects, so warning 414 is expected
#pragma warning disable 414
using System;
using System.Drawing;
using System.Diagnostics;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using UIKit;
using GLKit;
using Metal;
using MapKit;
using ModelIO;
using SceneKit;
using Security;
using AudioUnit;
using CoreVideo;
using CoreMedia;
using QuickLook;
using Foundation;
using CoreMotion;
using ObjCRuntime;
using AddressBook;
using CoreGraphics;
using CoreLocation;
using AVFoundation;
using NewsstandKit;
using CoreAnimation;
using CoreFoundation;
namespace EDQueue {
[Protocol (Name = "EDQueueDelegate", WrapperType = typeof (EDQueueDelegateWrapper))]
[ProtocolMember (IsRequired = false, IsProperty = false, IsStatic = false, Name = "Queue", Selector = "queue:processJob:", ReturnType = typeof (EDQueue.EDQueueResult), ParameterType = new Type [] { typeof (global::EDQueue.EDQueue), typeof (NSDictionary) }, ParameterByRef = new bool [] { false, false })]
public interface IEDQueueDelegate : INativeObject, IDisposable
{
}
// ETC...
}
但是,如果我删除或注释掉该[Protocol, Model]
位,则库会构建没有错误.
如果我用第二个函数取消注释,我也会得到类似的错误EDQueueCompletionBlock
,最终依赖于EDQueueResult
枚举.
该Structs.cs
文件的生成操作设置为ObjcBindingCoreSource
.
真的很感激任何帮助.谢谢!