Xamarin.ios MonoTouch绑定到小马调试器-PDDebugger.DefaultInstance始终为空
我正在为小马调试器编写一个绑定,应该很简单,对吧 通过类成员“defaultInstance”访问Pony 我是这样实现的:Xamarin.ios MonoTouch绑定到小马调试器-PDDebugger.DefaultInstance始终为空,xamarin.ios,xamarin,Xamarin.ios,Xamarin,我正在为小马调试器编写一个绑定,应该很简单,对吧 通过类成员“defaultInstance”访问Pony 我是这样实现的: [assembly: LinkWith ("libPonyDebugger.a", LinkTarget.Simulator, ForceLoad = true)] namespace PonyDebugger { [BaseType (typeof (NSObject))] interface PDDebugger {
[assembly: LinkWith ("libPonyDebugger.a", LinkTarget.Simulator, ForceLoad = true)]
namespace PonyDebugger
{
[BaseType (typeof (NSObject))]
interface PDDebugger
{
[Static] [Export ("defaultInstance")]
PDDebugger DefaultInstance { get; }
[Export ("enableViewHierarchyDebugging")]
PDDebugger EnableViewHierarchyDebugging();
}
}
我可以很好地编译绑定,但是当我调用“PDDebugger.DefaultInstance”时,我只返回null。我错过了什么
我怎样才能确保消息被传递到底层的ObjC对象
谢谢
[编辑]
我已将绑定更新为:
使用制度;
使用单调的基础;
使用MonoTouch.objc运行时
**libPonyDebugger.linkwith.cs**
[assembly: LinkWith ("libPonyDebugger.a", LinkTarget.Simulator, ForceLoad = true,
Frameworks = "Security CFNetwork Foundation CoreGraphics UIKit CoreData", LinkerFlags = "-ObjC -licucore")]
namespace PonyDebugger
{
[BaseType (typeof (NSObject), Name="PDDebugger")]//, DisableDefaultCtor]
interface PDDebugger
{
//+ (PDDebugger *)defaultInstance;
[Static, Export ("defaultInstance")]
PDDebugger DefaultInstance();
[Export ("enableViewHierarchyDebugging")]
PDDebugger EnableViewHierarchyDebugging();
}
}
using System;
using MonoTouch.ObjCRuntime;
[assembly: LinkWith ("libSocketRocket.a", LinkTarget.ArmV7 | LinkTarget.Simulator,
Frameworks = "Security CFNetwork Foundation CoreGraphics UIKit CoreData", ForceLoad = true, LinkerFlags = "-ObjC -licucore")]
**libSocketRocket.linkwith.cs**
[assembly: LinkWith ("libPonyDebugger.a", LinkTarget.Simulator, ForceLoad = true,
Frameworks = "Security CFNetwork Foundation CoreGraphics UIKit CoreData", LinkerFlags = "-ObjC -licucore")]
namespace PonyDebugger
{
[BaseType (typeof (NSObject), Name="PDDebugger")]//, DisableDefaultCtor]
interface PDDebugger
{
//+ (PDDebugger *)defaultInstance;
[Static, Export ("defaultInstance")]
PDDebugger DefaultInstance();
[Export ("enableViewHierarchyDebugging")]
PDDebugger EnableViewHierarchyDebugging();
}
}
using System;
using MonoTouch.ObjCRuntime;
[assembly: LinkWith ("libSocketRocket.a", LinkTarget.ArmV7 | LinkTarget.Simulator,
Frameworks = "Security CFNetwork Foundation CoreGraphics UIKit CoreData", ForceLoad = true, LinkerFlags = "-ObjC -licucore")]
所有这些都是b触摸/编译到本机并运行的,但是PDDebugger.DefaultInstance()仍然返回null。如果您得到null,可能意味着本机库没有正确链接
您是在模拟器上运行还是在设备上运行?您是如何编译绑定的?您确定本机库支持您正在测试的体系结构吗?我刚才做了一个绑定Ponydebuger的快速测试。绑定很好-但它不起作用,因为方法swizzling IIRC 通过快速查看,您的linkwith.cs看起来不完整。我的看法是:
[assembly: LinkWith ("libPonyDebugger.a", LinkTarget.ArmV7 | LinkTarget.Simulator,
ForceLoad = true,
Frameworks = "Security CFNetwork CoreData",
LinkerFlags = "-ObjC -licucore" )]
我还需要包括libSocketRocket.a
,因为我向小马添加了框架和标志,所以更简单
[assembly: LinkWith ("libSocketRocket.a", LinkTarget.ArmV7 | LinkTarget.Simulator,
ForceLoad = true)]
这将为您提供一个
PDDebugger
的非空实例,但您需要做更多的工作才能从中获得实际结果。遗憾的是,我没有时间进一步挖掘它,但是当您了解其余内容时,请告诉我们:-)Hi jstedfast-谢谢您的回复。我编译了它和模拟器的示例应用程序,然后将libPonyDebugger.a和libSocketRocket.a从DEveloper/XCode/DerivedData复制到我的项目目录中,并使用btouch-unsafe--outdir=tmp-out:PonyDebugger.dll libPonyDebugger.linkwith.cs--link with=libPonyDebugger.a,libPonyDebugger.a--link with=libSocketRocket.a,libSocketRocket.a-v
我认为你是对的-我不认为它正在加载,因为我在小马启动时会记录消息,但不会在控制台中显示它们。哦-我在模拟器中运行所有的操作-我实际上不需要设备支持…谢谢Poupou-希望这能让我走得更远一点。我已经添加了额外的框架(基本上是xcode项目中列出的所有内容),但是我在引用licucore中的某些内容时遇到了一个单本地链接器错误,我认为您已经找到了解决方案。我今晚试试看,然后回来汇报。我所需要的就是这个项目的UI检查。如果我能让它工作的话,我会把它全部贴出来。嗨,波波,你的帖子让我走得更远了一点,但还是没有回复。我已经更新了我的帖子。。。