We've been building messenger like app with share extension (from safari). Right now we've encountered a big problem Extension crashes when im trying to get url string
CRASH:
Tread 1
Unhandled Exception:
0 Mono 0x01746691 mono_handle_exception_internal + 2168
1 Mono 0x01745e13 mono_handle_exception + 30
2 Mono 0x0173ed2d mono_arm_throw_exception + 104
3 com.XXX.ShareExtension 0x00268e44 throw_exception + 64
at ObjCRuntime.Runtime.throw_ns_exception (intptr) [0x00000] in /Users/builder/data/lanes/2077/d8e9592a/source/maccore/runtime/Delegates.generated.cs:100 at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception (intptr) <0x00048>
6 com.XXX.ShareExtension 0x006fe5c0 xamarin_throw_ns_exception + 52
7 com.XXX.ShareExtension 0x007004b0 _ZL17exception_handlerP11NSException + 224
8 CoreFoundation 0x242cbba9 + 644
9 libobjc.A.dylib 0x35c7f087 + 174
10 libc++abi.dylib 0x35463e17 + 78
11 libc++abi.dylib 0x354638f7 __cxa_rethrow + 102
12 libobjc.A.dylib 0x35c7ef47 objc_exception_rethrow + 42
Which means mono crashes. Looking further I see:
Tread 2
iOS_ShareExtension[336] : Unhandled managed exception:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason:
NSGetSizeAndAlignment(): unsupported type encoding spec 'Y' at 'Y„ hŸ0iŸêoŸû' in 'Y„ hŸ0iŸêoŸû'
Native stack trace:
0 CoreFoundation 0x242cb883 + 150
1 libobjc.A.dylib 0x35c7edff objc_exception_throw + 38
2 CoreFoundation 0x242cce71 + 536
3 CoreFoundation 0x242cef69 + 60
4 CoreFoundation 0x241f9515 + 516
5 libextension.dylib 0x355c2e47 + 150
6 com.XXX.ShareExtension 0x000643f4 wrapper_managed_to_native_ObjCRuntime_Messaging_void_objc_msgSend_IntPtr_IntPtr_IntPtr_intptr_intptr_intptr_intptr_intptr + 128
7 com.XXX.ShareExtension 0x0003a5e8 Foundation_NSItemProvider_LoadItem_string_Foundation_NSDictionary_System_Action_2_Foundation_NSObject_Foundation_NSError + 384
8 com.XXX.ShareExtension 0x0000c5d4 iOS_ShareExtension_ShareViewController_ViewDidLoad + 1048
My code that crashes:
NSExtensionItem content = ExtensionContext.InputItems [0];
foreach (NSItemProvider item in content.Attachments) {
if (item.HasItemConformingTo ("public.url")){
item.LoadItem (UTType.URL,null, OnItemLoaded);
break;
}
}
and then:
NSUrl url = objectLoaded as NSUrl;
_sharedURl = url.AbsoluteString; // THIS CRASH!!!
Any idea how to bypass this? I've even tried coverting this NSUrl in various ways.