MonoTouch issues when binding ObjectiveC library

2019-08-16 15:24发布

I am trying to make bindings for the Vfr PDF reader: https://github.com/vfr/Reader This is an ObjectiveC application.

I followed the walkthrough from Xamarin there: http://docs.xamarin.com/guides/ios/advanced_topics/binding_objective-c/binding_walkthrough/

Unfortunately I am still struggling on one issue. In my AppDelegate I instantiate a ReaderDemoController, which comes from the Vfr Reader library but, when running on the device (an iPhone5), it keeps saying:

Wrapper type 'Hager.VfrReaderCoreBinding.ReaderDemoController' is missing its native ObjectiveC class 'ReaderDemoController'.

Which is strange since the Fat library contains i386, armv7, armv7s and arm64 libraries (done that using lipo). This is the LinkWith file content:

[assembly: LinkWith ("libVfrReaderCoreNative.a", LinkTarget.Simulator | LinkTarget.ArmV7 | LinkTarget.ArmV7s, ForceLoad = true)]

In the ApiDefinition file this is the ReaderController interface:

[BaseType (typeof (UIViewController))]
public interface ReaderDemoController {
}

Nothing really "complicated". Any idea of what could be the cause? This is the binding solution: solution zipped

This is also not working in the simulator. I get :

Could not create an native instance of the type 'Hager.VfrReaderCoreBinding.ReaderDemoController': the native class hasn't been loaded.

It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.

1条回答
贼婆χ
2楼-- · 2019-08-16 15:52

It looks like the Objectice-C library wasn't built correctly, if you run nm on it you'll see it's almost empty:

$ nm libVfrReaderCoreNative.a

libVfrReaderCoreNative.a(VfrReaderCoreNative.o):
0000000000000000 s L_OBJC_CLASS_NAME_
                 U _OBJC_CLASS_$_NSObject
00000000000000d0 S _OBJC_CLASS_$_VfrReaderCoreNative
                 U _OBJC_METACLASS_$_NSObject
00000000000000a8 S _OBJC_METACLASS_$_VfrReaderCoreNative
                 U __objc_empty_cache
                 U __objc_empty_vtable
0000000000000060 s l_OBJC_CLASS_RO_$_VfrReaderCoreNative
0000000000000018 s l_OBJC_METACLASS_RO_$_VfrReaderCoreNative

In particular nothing related to ReaderDemoController.

查看更多
登录 后发表回答