I am trying to use the camera in a Xamarin iOS app. First step seems to check if the app has access to the camera. But i get a fatal error in the mono runtime while doing this. Any idea?
Here are more details about the exception:
In Visual Studio (2015), I create a new "Blank App (iPhone)" project. Since I own a iPhone 3GS, I switch to armv7 in the project properties, and select iOS 6.1 as deployment target.
Build app, debug on iPhone: the mac agent works well, and the empty app starts on my phone.
Then I go to AppDelegate.FinishedLaunching(...) and add AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video); before returning true.
Rebuild app, debug... and an exception is being thrown by GetAuthorizationStatus(...). Here is its stacktrace:
2016-06-24 12:50:22.691 App2[491:907] +[AVCaptureDevice authorizationStatusForMediaType:]: unrecognized selector sent to class 0x3a49c070
2016-06-24 12:50:22.704 App2[491:907] critical: Stacktrace:
2016-06-24 12:50:22.708 App2[491:907] critical: at <0xffffffff>
2016-06-24 12:50:22.712 App2[491:907] critical: at <0xffffffff>
2016-06-24 12:50:22.715 App2[491:907] critical:
Native stacktrace:
2016-06-24 12:50:22.964 App2[491:907] critical: 0 App2 0x0004f49d mono_handle_native_sigsegv + 240
2016-06-24 12:50:22.968 App2[491:907] critical: 1 App2 0x00056a23 mono_sigsegv_signal_handler + 222
2016-06-24 12:50:22.971 App2[491:907] critical: 2 libsystem_c.dylib 0x3a37ee93 _sigtramp + 42
2016-06-24 12:50:22.975 App2[491:907] critical: 3 App2 0x0033d3d0 map_dwarf_reg_to_hw_reg + 0
2016-06-24 12:50:22.978 App2[491:907] critical: 4 App2 0x0004ed4f mono_handle_exception_internal + 1508
2016-06-24 12:50:22.982 App2[491:907] critical: 5 App2 0x0004e767 mono_handle_exception + 30
2016-06-24 12:50:22.985 App2[491:907] critical: 6 App2 0x0004819b mono_arm_throw_exception + 106
2016-06-24 12:50:22.989 App2[491:907] critical: 7 App2 0x00244194 throw_exception + 64
2016-06-24 12:50:22.996 App2[491:907] critical: 8 App2 0x00274c74 ObjCRuntime_Runtime_throw_ns_exception_intptr + 28
2016-06-24 12:50:23.000 App2[491:907] critical: 9 App2 0x002ab490 wrapper_native_to_managed_ObjCRuntime_Runtime_throw_ns_exception_intptr + 72
2016-06-24 12:50:23.004 App2[491:907] critical: 10 App2 0x000f1bac xamarin_throw_ns_exception + 52
2016-06-24 12:50:23.007 App2[491:907] critical: 11 App2 0x000f3a64 _ZL17exception_handlerP11NSException + 224
2016-06-24 12:50:23.011 App2[491:907] critical: 12 CoreFoundation 0x322a457f + 614
2016-06-24 12:50:23.014 App2[491:907] critical: 13 libobjc.A.dylib 0x39f00a65 + 128
2016-06-24 12:50:23.018 App2[491:907] critical: 14 libc++abi.dylib 0x3994d07b + 78
2016-06-24 12:50:23.025 App2[491:907] critical: 15 libc++abi.dylib 0x3994d114 + 19
2016-06-24 12:50:23.029 App2[491:907] critical: 16 libc++abi.dylib 0x3994e599 cxa_current_exception_type + 0
2016-06-24 12:50:23.032 App2[491:907] critical: 17 libobjc.A.dylib 0x39f009d1 objc_exception_rethrow + 12
2016-06-24 12:50:23.036 App2[491:907] critical: 18 CoreFoundation 0x321eaf21 CFRunLoopRunSpecific + 456
2016-06-24 12:50:23.039 App2[491:907] critical: 19 CoreFoundation 0x321ead49 CFRunLoopRunInMode + 104
2016-06-24 12:50:23.043 App2[491:907] critical: 20 UIKit 0x34103485 + 668
2016-06-24 12:50:23.046 App2[491:907] critical: 21 UIKit 0x34100301 UIApplicationMain + 1120
2016-06-24 12:50:23.054 App2[491:907] critical: 22 App2 0x002a6fec wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 252
2016-06-24 12:50:23.057 App2[491:907] critical: 23 App2 0x0026f8a4 UIKit_UIApplication_Main_string___intptr_intptr + 52
2016-06-24 12:50:23.064 App2[491:907] critical: 24 App2 0x0026f864 UIKit_UIApplication_Main_string___string_string + 204
2016-06-24 12:50:23.069 App2[491:907] critical: 25 App2 0x0010a8e8 App2_Application_Main_string + 152
2016-06-24 12:50:23.073 App2[491:907] critical: 26 App2 0x00223870 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 256
2016-06-24 12:50:23.078 App2[491:907] critical: 27 App2 0x0005842b mono_jit_runtime_invoke + 1562
2016-06-24 12:50:23.083 App2[491:907] critical: 28 App2 0x000991e7 mono_runtime_invoke + 102
2016-06-24 12:50:23.087 App2[491:907] critical: 29 App2 0x0009c799 mono_runtime_exec_main + 284
2016-06-24 12:50:23.092 App2[491:907] critical: 30 App2 0x0010a4c0 xamarin_main + 2232
2016-06-24 12:50:23.096 App2[491:907] critical: 31 App2 0x002b6d6d main + 112
2016-06-24 12:50:23.101 App2[491:907] critical: 32 libdyld.dylib 0x3a337b20 + 0
2016-06-24 12:50:23.106 App2[491:907] critical: Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
+[AVCaptureDevice authorizationStatusForMediaType:]: unrecognized selector sent to class 0x3a49c070
What is the version of iOS running on your device ?
select iOS 6.1 as deployment target.
Because if it's 6.1, like your deployment target, then you cannot call this API since it was added in iOS 7.0.
You need to conditionally call this on iOS 7.0+, e.g.
if (UIDevice.CurrentDevice.CheckSystemVersion (7,0)) {
AVCaptureDevice.GetAuthorizationStatus (AVMediaType.Video);
}
The assembly browser can show you, with attributes, the minimum version required for the API.