I have created an Objective-C library with one function in. The header is defined as:
@interface StarIOFunctions : NSObject {
}
+ (NSMutableData *) GetDataToSendToPrinter:(UIImage *)image maxWidth:(int)maxWidth drawerKick:(BOOL)drawerKick compressionEnable:(BOOL)compressionEnable;
@end
I have created a binding for it:
[BaseType (typeof (NSObject))]
interface StarIOFunctions {
[Static, Export ("GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:")]
NSMutableData GetDataToSendToPrinter (UIImage image, int maxWidth, bool kickDrawer, bool compressionEnable);
}
And the call it via:
image = UIImage.FromBundle("barcode.png");
NSMutableData commandsToPrint = StarIOFunctions.GetDataToSendToPrinter(image,576,true,true);
All works fine in the simulator, but when I release to device the app crashes when it tries to call the function with the following error:
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)
I have built the Objective-C library for device, and included that .a file in my bindings. My linkwith file is:
[assembly: LinkWith ("libStarIOFunctions.a", LinkTarget.ArmV7, ForceLoad = true)]
Why is it crashing on the iPad but not the simulator?
Edit: Build output is at http://pastebin.com/mtVgHA6L
Edit 2: I have just LIPO'ed my two version today. So my linkwith is now:
[assembly: LinkWith ("libStarIOFunctions.a", LinkTarget.Simulator | LinkTarget.ArmV7, ForceLoad = true)]
And still works fine in simulator and crashes with the following on device:
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