How to create iOS Bindings for private classes #34580
Unanswered
gitaakashstack
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a native iOS SDK Library which I have been trying to integrate in my MAUI app for iOS/Android via iOS Binding Project. The iOS SDK xcframework has certain classes in the headers folder which I suppose are public headers. First of all so far I know the binding can be created only for the classes which are part of public headers (correct me if I am wrong). I have been getting errors whenever I have tried to bind the classes in ApiDefinition.cs (of iOS Binding Project) which are not header files. The error when running the project on iOS Simultor (or even when running directly on iPad or iPhone) is something like:
clang++ exited with code 1: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_OPPCheckoutSettings", referenced from: <initial-undefines> ld: symbol(s) not found for architecture x86_64 clang++: error: linker command failed with exit code 1 (use -v to see invocation)Now this OPPCheckoutSettings class is not part of header folder in the native SDK. As soon as I remove OPPCheckoutSettings from bindings, this compiles and runs but eventually I need that class and some of its properties. I have already created bindings for a couple of classes which are part of public headers and they work. So this means the bindings are working. Now I would like to know from the community, as there is hardly any info available in docs, how do I create a binding or get an instance of a private class of native SDK.
One of the alternatives I tried using ObjCRuntime:
ObjCRuntime.Class.GetHandle("OPPCheckoutSettings")to get the class handle at runtime (probabaly from the binary) but it always return zero pointer. Infact getting handle of even the public class form the ObjCRuntime returns always zero pointer. So somehow cannot get any class handles during runtime via ObjCRuntime method. For this I did try MTouchLink to None in case the linker was discarding the sdk binaries but it still always give zero pointer. So is there any other way for bindings from private classes to make them work or can I do something on ObjCRuntime method so as to get the handle instance.
This is the link of a repo containing ApiDefinion.cs and csproj of iOS Binding Project: https://github.com/gitaakashstack/MauiIosSdkBinding.git
Thanks in advance....
Beta Was this translation helpful? Give feedback.
All reactions