我已遵循本指南 [ https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-sharpie/examples/cocoapod/]
并创建了一个绑定项目,添加了两个生成文件的内容绑定文件夹(AFNetworking_ApiDefinitions.cs 和 AFNetworking_StructsAndEnums.cs)。然后添加文件夹中的 AFNetworking.framework 作为对绑定项目的本地引用,并且有很多错误,除了这 4 个错误之外,我几乎解决了所有问题。
// -(BOOL)evaluateServerTrust:(SecTrustRef _Nonnull)serverTrustforDomain(NSString* _Nullable)domain;
[Export("evaluateServerTrust:forDomain:")]
unsafe bool EvaluateServerTrust(SecTrustRef* serverTrust, [NullAllowed] string domain);
}
错误 -/AFNetworkingBinding/AFNetworkingBinding/ApiDefinition.cs(34,34):错误 CS0246:找不到类型或命名空间名称“SecTrustRef”。您是否缺少程序集参考?(CS0246) (AFNetworkingBinding)
// -(instancetype _Nonnull)initWithReachability:(SCNetworkReachabilityRef _Nonnull)reachability __attribute__((objc_designated_initializer));
[Export("initWithReachability:")]
[DesignatedInitializer]
unsafe IntPtr Constructor(SCNetworkReachabilityRef* reachability);
错误 -Projects/AFNetworkingBinding/AFNetworkingBinding/ApiDefinition.cs(28,28):错误 CS0246:找不到类型或命名空间名称“SCNetworkReachabilityRef”。您是否缺少程序集参考?(CS0246) (AFNetworkingBinding)
// -(void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^ _Nullable)(NSURLSession * _Nonnull, NSURLAuthenticationChallenge * _Nonnull, NSURLCredential * _Nullable * _Nullable))block;
[Export("setSessionDidReceiveAuthenticationChallengeBlock:")]
unsafe void SetSessionDidReceiveAuthenticationChallengeBlock([NullAllowed] Func<NSUrlSession, NSUrlAuthenticationChallenge, Foundation.NSURLCredential*, NSUrlSessionAuthChallengeDisposition> block);
错误 - /Projects/AFNetworkingBinding/AFNetworkingBinding/ApiDefinition.cs(137,137):错误 CS0234:类型或命名空间名称NSURLCredential' does not exist in the namespace
Foundation'。您是否缺少程序集参考?(CS0234) (AFNetworkingBinding)
// -(void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^ _Nullable)(NSURLSession * _Nonnull, NSURLSessionTask * _Nonnull, NSURLAuthenticationChallenge * _Nonnull, NSURLCredential * _Nullable * _Nullable))block;
[Export("setTaskDidReceiveAuthenticationChallengeBlock:")]
unsafe void SetTaskDidReceiveAuthenticationChallengeBlock([NullAllowed] Func<NSUrlSession, NSUrlSessionTask, NSUrlAuthenticationChallenge, Foundation.NSURLCredential*, NSUrlSessionAuthChallengeDisposition> block);
错误 -/Projects/AFNetworkingBinding/AFNetworkingBinding/ApiDefinition.cs(152,152):错误 CS0234:类型或命名空间名称NSURLCredential' does not exist in the namespace
Foundation'。您是否缺少程序集参考?(CS0234) (AFNetworkingBinding)