Xamarin绑定在设备上失败,但在模拟器中工作
我创build了一个带有一个函数的Objective-C库。头文件被定义为:
@interface StarIOFunctions : NSObject { } + (NSMutableData *) GetDataToSendToPrinter:(UIImage *)image maxWidth:(int)maxWidth drawerKick:(BOOL)drawerKick compressionEnable:(BOOL)compressionEnable; @end
我为它创build了一个绑定:
[BaseType (typeof (NSObject))] interface StarIOFunctions { [Static, Export ("GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:")] NSMutableData GetDataToSendToPrinter (UIImage image, int maxWidth, bool kickDrawer, bool compressionEnable); }
而通过它的呼吁:
image = UIImage.FromBundle("barcode.png"); NSMutableData commandsToPrint = StarIOFunctions.GetDataToSendToPrinter(image,576,true,true);
所有在模拟器中工作正常,但是当我释放到设备的应用程序崩溃,当它试图调用具有以下错误的函数:
2014-09-30 19:10:52.776 DemoApp[280:26219] +[StarIOFunctions GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:]: unrecognized selector sent to class 0x14e787c 2014-09-30 19:11:14.697 DemoApp[280:26219] Unhandled managed exception: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: +[StarIOFunctions GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:]: unrecognized selector sent to class 0x14e787c (MonoTouch.Foundation.MonoTouchException) (null)
我已经为设备构build了Objective-C库,并将该.a文件包含在我的绑定中。 我的链接文件是:
[assembly: LinkWith ("libStarIOFunctions.a", LinkTarget.ArmV7, ForceLoad = true)]
为什么它会在iPad上崩溃而不是模拟器?
编辑 :生成输出在http://pastebin.com/mtVgHA6L
编辑2 :我今天刚刚LIPO了我的两个版本。 所以我的链接现在是:
[assembly: LinkWith ("libStarIOFunctions.a", LinkTarget.Simulator | LinkTarget.ArmV7, ForceLoad = true)]
并仍然在模拟器中正常工作,并在设备上使用以下方式崩溃:
2014-09-30 20:20:50.519 DemoApp[313:35575] +[StarIOFunctions GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:]: unrecognized selector sent to class 0x140887c 2014-09-30 20:20:50.521 DemoApp[313:35575] MonoTouch: Received unhandled ObjectiveC exception: NSInvalidArgumentException +[StarIOFunctions GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:]: unrecognized selector sent to class 0x140887c libc++abi.dylib: terminate_handler unexpectedly threw an exception