Skip to content

.NET 6 iOS support #1282

Closed
Closed
@bruno-garcia

Description

@bruno-garcia

Since .NET 6 landed (#939 ) we can look into adding net6-ios and including sentry-cocoa.
See: https://github.com/xamarin/xamarin-macios/blob/861c40dbe45478b848ac1d165314e05de012bf0f/tests/dotnet/NativeXCFrameworkReferencesApp/shared.csproj

When we bundle the Sentry iOS SDK we need to take into account that Mono uses some signals to interpret NullReferenceExceptions and need special case (run before other crash reports do):

See: https://www.mono-project.com/docs/advanced/signals/#incomplete-solution
See also: dotnet/runtime#44736

This is probably something we can do in the binding project, before calling Init in the iOS SDK.

Proposed solution, based on the Mono docs:

try {
} finally {
    Mono.Runtime.RemoveSignalHandlers ();
    try {
        // Init the Sentry iOS SDK:
        SentrySDK.start(...);
    } finally {
        Mono.Runtime.InstallSignalHandlers ();
    }
}

Since Mono’s signal handlers are reinstalled and not restored, Mono will now chain to the signal handlers installed by EnableCrashReporting.

The code is executed in a finally block, so that the Mono runtime will never abort it under any circumstance.

It’s recommended to do this as early as possible when launching the process, in particular before starting any secondary threads. If any signals are raised between removing and reinstalling Mono’s signal handlers (this includes NullReferenceExceptions), the app will crash.

See: https://www.mono-project.com/docs/advanced/signals/#complete-solution

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions