-
-
Notifications
You must be signed in to change notification settings - Fork 226
Description
Package
Sentry.Maui
.NET Flavor
.NET
.NET Version
MAUI 9+
OS
iOS
OS Version
No response
Development Environment
Visual Studio v17.x
SDK Version
5.6.0 and latest
Self-Hosted Sentry Version
No response
Workload Versions
My MAUI iOS app is crashing in launch in Simulator 18. MAUI 9,
System.Exception: Could not create an native instance of the type 'Sentry.CocoaSdk.SentryOptions': the native class hasn't been loaded.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
at Foundation.NSObject.InitializeObject(Boolean alloced)
at Foundation.NSObject..ctor(NSObjectFlag x)
at Sentry.CocoaSdk.SentryOptions..ctor()
at Sentry.SentrySdk.InitSentryCocoaSdk(SentryOptions options)
at Sentry.SentrySdk.InitHub(SentryOptions options)
at Sentry.SentrySdk.Init(SentryOptions options)
at Sentry.Maui.Internal.SentryMauiInitializer.Initialize(IServiceProvider services)
at Microsoft.Maui.Hosting.MauiAppBuilder.Build()
at Sentry.reproduce.MauiProgram.CreateMauiApp() in /private/tmp/Sentry.reproduce/Sentry.reproduce/MauiProgram.cs:line 33
at Sentry.reproduce.AppDelegate.CreateMauiApp() in /private/tmp/Sentry.reproduce/Sentry.reproduce/Platforms/MacCatalyst/AppDelegate.cs:line 8
at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
I tried the suggested workaround, but it didn’t resolve the issue. In fact, adding the following snippet—as per the workaround—causes another library to break:
---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
<PropertyGroup>
<_LibXamarinLinkMode>static</_LibXamarinLinkMode>
<_LibMonoLinkMode>static</_LibMonoLinkMode>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<Target Name="_OverwriteReferencesLinkerFlags" BeforeTargets="_LinkNativeExecutable">
<!-- Remove the `-u` prefix from `_ReferencesLinkerFlags` so we can give the output file to the platform linker -->
<!-- NOTE: This step is actually also done after LinkNativeCode task, but we cannot intercept it differently -->
<WriteLinesToFile SessionId="$(BuildSessionId)" File="$(_MtouchSymbolsList)" Lines="@(_ReferencesLinkerFlags->'%(Identity)'->Substring (2))" Overwrite="true" />
<ItemGroup>
<!-- Backup collected required symbols -->
<_ReferencesLinkerFlagsBackup Include="@(_ReferencesLinkerFlags)" />
<!-- Clear `_ReferencesLinkerFlags` to prevent required symbols to be passed in -u_symbolName format -->
<_ReferencesLinkerFlags Remove="@(_ReferencesLinkerFlags)" />
<!-- Instruct platform linker to only export required symbols -->
<_ReferencesLinkerFlags Include="-exported_symbols_list" />
<_ReferencesLinkerFlags Include="$(_MtouchSymbolsList)" />
</ItemGroup>
</Target>
<Target Name="_RestoreReferencesLinkerFlags" AfterTargets="_LinkNativeExecutable">
<ItemGroup>
<_ReferencesLinkerFlags Remove="@(_ReferencesLinkerFlags)" />
<_ReferencesLinkerFlags Include="@(_ReferencesLinkerFlagsBackup)" />
</ItemGroup>
</Target>
UseSentry or SentrySdk.Init call
.UseSentry(options =>
{
// The DSN is the only required setting.
options.Dsn = "aaaaabbbbb;
#if DEBUG
options.Debug = true;
#else
options.Debug = false;
#endif
options.SendDefaultPii = true;
options.AutoSessionTracking = true;
options.IsGlobalModeEnabled = true;
options.AttachStacktrace = true;
options.AttachScreenshot = true;
options.CaptureFailedRequests = true;
})
Steps to Reproduce
Include Sentry nuget and just compile the app
app launch getting crashed
Expected Result
the app should not crash
Actual Result
app crash as below stacktrace
Metadata
Metadata
Assignees
Labels
Projects
Status
Status