无法创建“FWSImageRepo”类型的本机实例。原生类尚未加载

Jay*_*nan 5 objective-c xamarin.ios xamarin.ios-binding

我正在尝试链接一个AFNetworking内部使用的本机 iOS 框架,我最初将其构建为原型,以便将来将我公司的一些 ObjC IP 转移到可与 Xamarin 链接。

我首先创建一个简单的类,使用 AFNetworking 将小猫加载到 UIImageView 中

头文件:

#import <UIKit/UIKit.h>

@interface FWSImageRepo : NSObject
+(UIImageView *)imageViewFromURLString:(NSString *)urlString;
@end
Run Code Online (Sandbox Code Playgroud)

执行

@implementation FWSImageRepo

+(UIImageView *)imageViewFromURLString:(NSString *)urlString{

    UIImageView *imageView = [[UIImageView alloc] init];

    NSURL *imageUrl= [NSURL URLWithString:@"http://www.pets4homes.co.uk/images/articles/1334/large/6-health-issues-to-watch-for-in-young-kittens-52f62cff5cabb.jpg"];

    if(imageUrl != nil) {
        [imageView setImageWithURL:imageUrl];
    }

    return imageView;
}

@end
Run Code Online (Sandbox Code Playgroud)

我创建了一个框架编译器目标,并将该框架复制到 Xamarin iOS 项目。我使用 Objective Sharpie 生成下面的绑定

// @interface FWSImageRepo : NSObject
[BaseType(typeof(NSObject))]
interface FWSImageRepo
{
    // +(UIImageView *)imageViewFromURLString:(NSString *)urlString;
    [Static]
    [Export("imageViewFromURLString:")]
    UIImageView ImageViewFromURLString(string urlString);
}
Run Code Online (Sandbox Code Playgroud)

所有这些都按照 中的指示链接binding project,框架作为本机引用链接,绑定项目由单页 Xamarin iOS 应用程序引用。

现在,仅仅对类进行初始化var fwrepo = new FWSImageRepo();就表明该项目根本不喜欢该框架。即使我不链接绑定项目中的框架,错误也不会改变

Could not create an native instance of the type 'FWSImageRepo': the native class hasn't been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
Run Code Online (Sandbox Code Playgroud)

有什么理由检查发生了什么吗?我已经尝试了一切并用尽了网上的搜索。据我搜索,在任何地方都没有此要求的示例,也几乎没有任何方向。我已经尝试过其他面临同样问题的解决方案。我该如何查找哪里出了问题?

这是我创建的项目的链接https://drive.google.com/open?id=0B2f9RlRxZKoZcElIRkpLZnF6WVU

Chr*_*ons 1

无法创建“FWSImageRepo”类型的本机实例:尚未加载本机类。通过将 ObjCRuntime.Class.ThrowOnInitFailure 设置为 false 可以忽略此情况。

这表明有问题的本机库尚未加载。我会浏览文档:

https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/

确定项目设置未加载到本机库中的位置。