c# - Xamarin 绑定(bind) "Wrapper type '' 缺少其 native ObjectiveC 类

标签 c# ios binding xamarin.ios xamarin

我正在尝试将外部附件 MSR SDK 绑定(bind)到 Xamarin。请注意,这是在设备上。它在模拟器中根本不起作用。我不断收到此错误:

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

这是我的 .cs 和我的链接器标志:

[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 

如能提供有关绑定(bind)此库的任何帮助,我们将不胜感激。几个小时以来,我一直在努力解决这个问题。

最佳答案

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

最常见的原因是:

  • 类(class)名称中的拼写错误。
  • native 库不包含您正在构建的架构。例如, native 库需要包含 i386 代码才能在模拟器中运行。您可以使用 lipo 工具列出 native 库中的体系结构:

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

    您还需要了解应用所使用的架构,您可以在项目的 iOS build设置中的“高级”页面上进行检查。选择 native 库包含的一个。

  • 绑定(bind)项目中的 native 库依赖于另一个不在绑定(bind)项目中的 native 库(IMag 类在另一个库中)。必须包含所有非平台依赖项。

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

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

    以上结果表明该类包含在 native 库中。

关于c# - Xamarin 绑定(bind) "Wrapper type '' 缺少其 native ObjectiveC 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24316352/

相关文章:

c# - 在单元测试中模拟 HttpPostedFile

c# - 如何使用 Win32API 在其他进程中滚动窗口

objective-c - Ooyala 播放器 (iOS) : how to start in full screen?

wpf - 是否可以 'refresh' WPF 数据绑定(bind)

language-agnostic - 语言绑定(bind)如何工作?

xaml - Xamarin 表单 : How to reference to the parent binding

c# - WCF nettcp 回调在部署时不起作用

c# - 如何获取枚举的属性

ios - 如何在alert.addTextfield中放置$硬币掩码?

ios - 在 Xcode 9 上安装 iOS12 模拟器