xamarin / GoogleApisForiOSComponents

MIT License
225 stars 156 forks source link

Firebase.Crashlytics.StackFrame.Create(nuint address) has wrong method selector #652

Open aliyailina opened 3 months ago

aliyailina commented 3 months ago

Calling Firebase.Crashlytics.StackFrame.Create(nuint address) causes unrecognized selector exception.

[Export] attribute has wrong selector parameter stackFrameWithAddress:address, while it must be stackFrameWithAddress:.

Workaround

You can invoke method directly as described in documentation.

Declare this method somewhere (usually, in class where you use it):

[DllImport("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
internal static extern IntPtr IntPtr_objc_msgSend_UIntPtr(IntPtr receiver, IntPtr selector, UIntPtr arg1);

Then use it like this:

using ObjCRuntime;
using Firebase.Crashlytics;

...

var stackFramePointer = IntPtr_objc_msgSend_UIntPtr(new Class(typeof(StackFrame)).Handle, Selector.GetHandle("stackFrameWithAddress:"), (UIntPtr)address);
var stackFrame = Runtime.GetNSObject<StackFrame>(stackFramePointer);