question

ldegianni-7448 avatar image
0 Votes"
ldegianni-7448 asked WenyanZhang-MSFT commented

Xamarin.iOS Project Crashes On Startup With Auth0.OidcClient and SfListViewRenderer With Linking Enabled

I am experiencing a crash on startup for my iOS project. The crash only occurs in release mode and not in debug mode. I have "Link Framework SDKs Only" enabled for release mode. If I disable linking for the release configuration then the app runs as expected. I have also found that if I comment out one of the lines:

 SfListViewRenderer.Init(); //Problem line 1.

or:

 ActivityMediator.Instance.Send(url.AbsoluteString); //Problem line 2.

then the app launches without crashing. Only when both lines are present with linking enabled does the crash occur. Here is the AppDelegate.cs:

 using Auth0.OidcClient;
 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 Rg.Plugins.Popup;
 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.iOS.ComboBox;
 using Syncfusion.XForms.iOS.ProgressBar;
 using Syncfusion.XForms.Pickers.iOS;
 using Xamarin.Forms.Platform.iOS;
 using Syncfusion.XForms.iOS.Border;
 using Syncfusion.SfGauge.XForms.iOS;
 using Syncfusion.SfChart.XForms.iOS.Renderers;
 using Xamarin.Forms;
 using Sharpnado.Shades.iOS;
 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 partial class AppDelegate : 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)
         {
             Forms.SetFlags("UseLegacyRenderers");
             Forms.Init();
    
             IQKeyboardManager.SharedManager.Enable = true;
    
             iOSShadowsRenderer.Initialize();
    
             new SfRangeSliderRenderer();
             new SfRotatorRenderer();
             new SfNumericTextBoxRenderer();
             new SfBusyIndicatorRenderer();
             new SfAutoCompleteRenderer();
    
             CardsViewRenderer.Preserve();
    
             Popup.Init();
    
             SfListViewRenderer.Init(); //Problem line 1.
             SfEffectsViewRenderer.Init();
             SfCardLayoutRenderer.Init();
             SfCarouselRenderer.Init();
             SfKanbanRenderer.Init();
             SfGaugeRenderer.Init();
             SfComboBoxRenderer.Init();
             SfPopupLayoutRenderer.Init();
             SfChartRenderer.Init();
             SfLinearProgressBarRenderer.Init();
             SfTextInputLayoutRenderer.Init();
             SfBorderRenderer.Init();
             SfButtonRenderer.Init();
             SfSegmentedControlRenderer.Init();
             SfChipRenderer.Init();
             SfChipGroupRenderer.Init();
             SfCheckBoxRenderer.Init();
             SfTimePickerRenderer.Init();
             SfSwitchRenderer.Init();
             SfPullToRefreshRenderer.Init();
             SfCalendarRenderer.Init();
    
             UIApplication.SharedApplication.StatusBarHidden = true;
    
             LoadApplication(new App());
    
             return base.FinishedLaunching(app, options);
         }
    
         //This method is required for using the OidcClient on iOS.
         public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
         {
             ActivityMediator.Instance.Send(url.AbsoluteString); //Problem line 2.
    
             return true;
         }
     }
 }

Does anyone have any insight into what may be happening? Does anyone have any recommendations for troubleshooting?

dotnet-xamarinformsdotnet-ios
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ldegianni-7448 avatar image
0 Votes"
ldegianni-7448 answered WenyanZhang-MSFT commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for sharing this solution.

0 Votes 0 ·