Xamarin.Forms iOS Application Crashes With ActivityMediator In AppDelegate

Here is my AppDelegate.cs file:

using Foundation;
using PanCardView.iOS;
using Syncfusion.ListView.XForms.iOS;
using Syncfusion.SfAutoComplete.XForms.iOS;
using Syncfusion.SfBusyIndicator.XForms.iOS;
using Syncfusion.SfCalendar.XForms.iOS;
using Syncfusion.SfCarousel.XForms.iOS;
using Syncfusion.SfKanban.XForms.iOS;
using Syncfusion.SfNumericTextBox.XForms.iOS;
using Syncfusion.SfPullToRefresh.XForms.iOS;
using Syncfusion.SfRangeSlider.XForms.iOS;
using Syncfusion.SfRotator.XForms.iOS;
using Syncfusion.XForms.iOS.Buttons;
using Syncfusion.XForms.iOS.Cards;
using Syncfusion.XForms.iOS.EffectsView;
using Syncfusion.XForms.iOS.PopupLayout;
using Syncfusion.XForms.iOS.TextInputLayout;
using Syncfusion.XForms.Pickers.iOS;
using Auth0.OidcClient;
using UIKit;
using Xamarin;

namespace VulcanApp.iOS
{
    // The UIApplicationDelegate for the application. This class is responsible for launching the 
    // User Interface of the application, as well as listening (and optionally responding) to 
    // application events from iOS.
    [Register("AppDelegate")]
    public class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        //
        // This method is invoked when the application has loaded and is ready to run. In this 
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Xamarin.Forms.Forms.SetFlags("UseLegacyRenderers");
            Xamarin.Forms.Forms.Init();
            IQKeyboardManager.SharedManager.Enable = true;
            Sharpnado.Shades.iOS.iOSShadowsRenderer.Initialize();
            SfEffectsViewRenderer.Init();
            SfCardLayoutRenderer.Init();
            SfCarouselRenderer.Init();
            SfKanbanRenderer.Init();
            Syncfusion.SfGauge.XForms.iOS.SfGaugeRenderer.Init();
            SfListViewRenderer.Init();
            new SfRangeSliderRenderer();
            Syncfusion.XForms.iOS.ComboBox.SfComboBoxRenderer.Init();
            SfPopupLayoutRenderer.Init();
            Syncfusion.SfChart.XForms.iOS.Renderers.SfChartRenderer.Init();
            SfEffectsViewRenderer.Init();
            Syncfusion.XForms.iOS.ProgressBar.SfLinearProgressBarRenderer.Init();
            Syncfusion.XForms.iOS.Border.SfBorderRenderer.Init();
            new SfRotatorRenderer();
            CardsViewRenderer.Preserve();
            SfTextInputLayoutRenderer.Init();
            LoadApplication(new App());
            Syncfusion.XForms.iOS.Border.SfBorderRenderer.Init();
            SfButtonRenderer.Init();
            SfSegmentedControlRenderer.Init();
            new SfNumericTextBoxRenderer();
            SfChipRenderer.Init();
            SfChipGroupRenderer.Init();
            SfCheckBoxRenderer.Init();
            new SfBusyIndicatorRenderer();
            SfTimePickerRenderer.Init();
            SfSwitchRenderer.Init();
            Rg.Plugins.Popup.Popup.Init();
            new SfAutoCompleteRenderer();
            SfPullToRefreshRenderer.Init();
            SfCalendarRenderer.Init();
            UIApplication.SharedApplication.StatusBarHidden = true;
            return base.FinishedLaunching(app, options);
        }

        public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
        {
            base.OpenUrl(application, url, sourceApplication, annotation);
            ActivityMediator.Instance.Send(url.AbsoluteString);

            return true;
        }
    }
}

I am finding that the application runs as expected in Debug mode, but crashes on open in Release. If I disable the linker in the Release configuration then the crash goes away. If I comment out the line:

ActivityMediator.Instance.Send(url.AbsoluteString);

and then rebuild the app with linking enabled the crash goes away.

Has anyone encountered this issue? Does anyone have recommendations for troubleshooting?

Hey there!

The most effective way to handle that would be to raise a GitHub issue on that, then share it here so we can ping repo maintainers and work on that directly with them.

1 Like

I was able to find a solution. From my understanding the dynamic registrar was being removed causing this exception: ObjCRuntime.RuntimeException: Can't register the class Plugin.BLE.BleCentralManagerDelegate when the dynamic registrar has been linked away. I am not sure why this was happening, but adding the following flag in Additional mtouch arguments fixed the crash: --optimize=-remove-dynamic-registrar

Woooohoo! Thanks for sharing that with the rest of community!