Xamarin绑定“包装器类型"缺少其本机的ObjectiveC类 [英] Xamarin Binding "Wrapper type '' is missing its native ObjectiveC Class

查看:52
本文介绍了Xamarin绑定“包装器类型"缺少其本机的ObjectiveC类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将外部附件MSR SDK绑定到Xamarin.注意,这在设备上.它根本无法在模拟器中工作.我不断收到此错误:

I am trying to bind an external accessory MSR SDK to Xamarin. Note, this is ON the device. It does not work in the simulator at all. I keep getting this error:

Wrapper type 'iMagProII.IMag' is missing its native ObjectiveC class 'IMag'.

这是带有链接器标志的.cs文件:

Here is my .cs with my linker flags:

[assembly: LinkWith ("libiMagSDK.a", LinkTarget = LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTarget.Simulator, SmartLink = true, ForceLoad = true, IsCxx = true, Frameworks = "CoreGraphics ExternalAccessory", LinkerFlags="-lsqlite3.0 -lc++")]

这是堆栈跟踪:

 at MonoTouch.Registrar.DynamicRegistrar.OnRegisterType (MonoTouch.Registrar.ObjCType type) [0x00334] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.DynamicRegistrar.cs:573 
  at MonoTouch.Registrar.Registrar.RegisterTypeUnsafe (System.Type type, System.Collections.Generic.List`1& exceptions) [0x009a4] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Registrar.cs:1027 
  at MonoTouch.Registrar.Registrar.RegisterType (System.Type type, System.Collections.Generic.List`1& exceptions) [0x00011] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Registrar.cs:680 
  at MonoTouch.Registrar.DynamicRegistrar.Register (System.Type type) [0x00002] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.DynamicRegistrar.cs:839 
  at MonoTouch.ObjCRuntime.Class.Register (System.Type type) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Class.cs:126 
  at MonoTouch.ObjCRuntime.Class.GetHandle (System.Type type) [0x00000] in <filename unknown>:0 
  at MonoTouch.Foundation.NSObject.AllocIfNeeded () [0x00015] in /Developer/MonoTouch/Source/maccore/src/Foundation/.pmcs-compat.NSObject2.cs:390 
  at MonoTouch.Foundation.NSObject..ctor (MonoTouch.Foundation.NSObjectFlag x) [0x00006] in /Developer/MonoTouch/Source/maccore/src/Foundation/.pmcs-compat.NSObject2.cs:102 
  at iMagProII.IMag..ctor () [0x00000] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII/obj/Debug/ios/iMagProII/IMag.g.cs:112 
  at iMagProII.iOS.ImagViewController.ViewDidLoad () [0x0005c] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/ImagViewController.cs:46 
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
  at MonoTouch.UIKit.UIViewController.get_View () [0x00030] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/.pmcs-compat.UIViewController.g.cs:2232 
  at iMagProII.iOS.ImagViewController..ctor () [0x00008] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/ImagViewController.cs:23 
  at iMagProII.iOS.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00016] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/AppDelegate.cs:33 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38 
  at iMagProII.iOS.Application.Main (System.String[] args) [0x00008] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/Main.cs:17 

在此库绑定方面的任何帮助将不胜感激.我已经好几个小时不停地动脑筋了.

Any help on getting this library bound would be greatly appreciated. I have been banging my head at it for hours now.

推荐答案

当在最终可执行文件中找不到类IMag时,就会发生这种情况.

This occurs when the class IMag can't be found in the final executable.

最常见的原因是:

  • 班级名称有错字.
  • 本机库不包含您要为其构建的体系结构.例如,本机库需要包含i386代码才能在模拟器中运行.您可以使用lipo工具列出本机库中的体系结构:

  • A typo in the class name.
  • The native library does not include the architecture you're building for. For instance the native library needs to contain i386 code to run in the simulator. You can use the lipo tool to list the architectures in the native library:

$ lipo -info /path/to/libiMagSDK.a

您还需要了解该应用程序所使用的体系结构,可以在项目的iOS Build设置中的高级"页面上对此进行检查.选择本机库包含的一个.

You also need to know the architecture you're using for the app, you can check this in the project's iOS Build settings, on the Advanced page. Select one that the native library includes.

绑定项目中的本机库依赖于另一个不在绑定项目中的本机库(IMag类在该其他库中).必须包含所有非平台依赖项.

The native library in the binding project depends on another native library which is not in the binding project (and the IMag class is in that other library). All non-platform dependencies must be included.

本机库构建不正确,并且不包含您尝试绑定的类(这种情况并不常见,但我仍然见过好几次).您可以使用nm工具检查本机库中包含的内容:

The native library is incorrectly built, and doesn't include the class you're trying to bind (this is not frequent, but I've still seen it several times). You can use the nm tool to check what's included in a native library:

$ nm -arch armv7 /path/to/libiMagSDK.a | grep IMag
0x0000f00d S _OBJC_CLASS_$_IMag
[other results]

以上结果表明该类已包含在本机库中.

The above result would indicate that the class is included in the native library.

这篇关于Xamarin绑定“包装器类型"缺少其本机的ObjectiveC类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆