Sentry.Maui doesn't work when deploying for iOS using "Hot Restart"
See original GitHub issuePackage
Sentry.Maui
.NET Version
6.0.304
OS
iOS
SDK Version
3.21.0-preview.3
Steps to Reproduce
- Create a MAUI Application
- Add Sentry NuGet
- Add Following code:
builder.UseSentry(options =>
{
// The DSN is the only required setting.
options.Dsn = "MY DSN";
// Use debug mode if you want to see what the SDK is doing.
// Debug messages are written to stdout with Console.Writeline,
// and are viewable in your IDE's debug console or with 'adb logcat', etc.
// This option is not recommended when deploying your application.
#if DEBUG
options.Debug = true;
#endif
// Set TracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
options.TracesSampleRate = 1.0;
options.AttachStacktrace = true;
#if ANDROID
options.Android.AttachScreenshot = true;
#endif
options.CacheDirectoryPath = FileSystem.Current.AppDataDirectory;
});
- Build & Launch with Hot Restart on a Iphone (Iphone SE 2020)
Expected Result
The application launch without any error or crash
Actual Result
The application crash.
[0:] An error occurred: ‘Could not create an native instance of the type ‘SentryCocoa.SentryOptions’: the native class hasn’t been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.’. Callstack: ’ at Foundation.NSObject.InitializeObject(Boolean alloced) at Foundation.NSObject…ctor(NSObjectFlag x) at SentryCocoa.SentryOptions…ctor() in //src/Sentry/obj/Release/net6.0-ios/iOS/SentryCocoa/SentryOptions.g.cs:line 59 at Sentry.SentrySdk.InitSentryCocoaSdk(SentryOptions options) in //src/Sentry/Platforms/iOS/SentrySdk.cs:line 22 at Sentry.SentrySdk.InitHub(SentryOptions options) in //src/Sentry/SentrySdk.cs:line 60 at Sentry.SentrySdk.Init(SentryOptions options) in //src/Sentry/SentrySdk.cs:line 109 at Sentry.Maui.Internal.SentryMauiInitializer.Initialize(IServiceProvider services) in /_/src/Sentry.Maui/Internal/SentryMauiInitializer.cs:line 12 at Microsoft.Maui.Hosting.MauiAppBuilder.Build() at Mobile.MauiProgram.CreateMauiApp() in C:\Users\m\source\repos\Mobile\MauiProgram.cs:line 35 at Mobile.AppDelegate.CreateMauiApp() in C:\Users\m\source\repos\Mobile\Platforms\iOS\AppDelegate.cs:line 8 at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions) at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) at Mobile.Program.Main(String[] args) in C:\Users\m\source\repos\Mobile\Platforms\iOS\Program.cs:line 13 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)’
Issue Analytics
- State:
- Created a year ago
- Comments:24 (17 by maintainers)
Top GitHub Comments
This one worked for me, in the bare-bones sample that I posted, and in two other, more functional apps. I think you’ve got it, at least for me, at least for now. Tx
This is resolved in the latest 3.24.0 release. Thanks all!