首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xamarin绑定“包装类型”丢失了它的本机ObjectiveC类

Xamarin绑定“包装类型”丢失了它的本机ObjectiveC类
EN

Stack Overflow用户
提问于 2014-06-19 21:15:29
回答 1查看 1.7K关注 0票数 3

我试图绑定一个外部附件MSR到Xamarin。注意,这是在设备上。它在模拟器里根本不工作。我一直在犯这个错误:

代码语言:javascript
复制
Wrapper type 'iMagProII.IMag' is missing its native ObjectiveC class 'IMag'.

下面是我的带有链接器标志的.cs:

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

这里是堆栈跟踪:

代码语言:javascript
复制
 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 

如能对此库进行绑定,我们将不胜感激。我已经努力了好几个小时了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-19 21:51:42

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

造成这种情况的最常见原因是:

  • 类名中的一个错误。
  • 本机库不包括您要构建的体系结构。例如,本机库需要包含在模拟器中运行的i386代码。您可以使用lipo工具列出本机库中的体系结构: $ lipo -info /path/to/libiMagSDK.a 您还需要知道应用程序使用的体系结构,您可以在高级页面上的项目的iOS构建设置中检查这一点。选择本机库包含的一个。
  • 绑定项目中的本机库依赖于不在绑定项目中的另一个本机库(而且IMag类位于该其他库中)。必须包括所有非平台依赖项。
  • 本机库构建错误,没有包含要绑定的类(这并不常见,但我仍然多次看到)。您可以使用nm工具检查本机库中包含的内容: $ nm -arch armv7 /path/to/libiMagSDK.a \ grep IMag 0x0000f00d S _OBJC_CLASS_$_IMag其他结果 上面的结果表明类包含在本机库中。
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24316352

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档