iOS native library binding

IvanVlasenkoIvanVlasenko USMember ✭✭
edited November 2019 in Xamarin.iOS

The problem has already been discussed earlier, but I got it after the update in September.
Environment: the latest vs studio for mac, all the frameworks are updated, I also tried to switch to the preview channel, the error is the same.
Actually the problem: after the update, the error of creating a native object began to appear.

From my renderer to -
at Foundation.NSObject.InitializeObject (System.Boolean alloced) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/Foundation/NSObject2.cs:196
at Foundation.NSObject..ctor (Foundation.NSObjectFlag x) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/Foundation/NSObject2.cs:131
at UIKit.UIResponder..ctor (Foundation.NSObjectFlag t) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/UIResponder.g.cs:69
at UIKit.UIView..ctor (Foundation.NSObjectFlag t) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/UIView.g.cs:83

Error message:
Could not create an native instance of the type 'xxx': the native class hasn't been loaded.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.

if set ObjCRuntime.Class.ThrowOnInitFailure = false; - native constructor returns null;

lib in Binding project is fat, all architectures are supported. i have no its code, only headers. ApiDefinition and Structs generated by sharpie, and works well.

mtouch options: --optimize=-remove-dynamic-registrar

please give some ways to solve, project is on fire..
If exist way to rollback all mono frameworks i can try, but its not good way.````

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Two possible things to try:

    1. Make sure that the native library (.a file) is built to support the architecture you are deploying to.
    2. Make sure your linkwith.cs file (you may or may not have this depending on how you added the native library to your binding project), or whatever file has your LinkWith attribute is set to compile and is added to your project.

    Refer https://forums.xamarin.com/discussion/comment/282919/#Comment_282919.

  • IvanVlasenkoIvanVlasenko USMember ✭✭

    @ColeX Thank you for the answer.
    I have ios binding project, and add library as native reference. I have no linkWith file.
    Library have all Architectures in the fat file: libGZCameraSDK.a are: i386 armv7 armv7s x86_64 arm64

Sign In or Register to comment.