Xamarin.iOS app crashes on startup on iOS13

Are you using Bluetooth? If so, have you added keys NSBluetoothPeripheralUsageDescription and NSBluetoothAlwaysUsageDescription to your Info.plist? My application crashed on start after updating to iOS 13 until I added them.


To get console output for a crash like this on a release version on device:
connect your device to your Mac
open XCode
go to Window -> Devices and Simulators
click Open Console for your device
type your app name in the search window to filter the output

I found the exception that way. The crash log posted in the question didn't help, because it's just the apple main thread crashing.

For us the crash was caused by using a deprecated class, namely UISearchDisplayController, which should be replaced by UISearchController.
It continued to work in iOS12, but not in iOS13. It was deprecated in iOS8 though i think, so fair enough.

You may have to upload the app to App Store Connect and run it via TestFlight to see the logs, not sure.

Also, this is probably irrelevant, but go to your iPhone settings -> privacy -> Analytics -> Share with App Developers and Share iPhone Analytics


Crash was caused by this code:

var allNotifications = UIApplication.SharedApplication.ScheduledLocalNotifications;
foreach (var notification in allNotifications)
{
...
}

In iOS 12 and earlier UIApplication.SharedApplication.ScheduledLocalNotifications returns empty array if there are not any scheduled local notifications. In iOS 13 it returns null. So adding a null check fixed the issue.

It may return null also because the API UIApplication.SharedApplication.ScheduledLocalNotifications has been deprecated since iOS 10. I upgraded now to the new API UNUserNotificationCenter.GetPendingNotificationRequests and noticed that the null check is needed also with the new API.