Skip to content

Commit

Permalink
InitSentryCocoaSdk - Native AOT | set marshal-managed-exceptions at…
Browse files Browse the repository at this point in the history
… compilation instead of runtime
  • Loading branch information
bricefriha committed Nov 8, 2024
1 parent fa4d434 commit 191776c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<Project>

<!--
Workaround for https://github.com/xamarin/xamarin-macios/issues/15252
ensuring that Native AOT compile code does not get the wrong marshal-managed-exceptions
-->
<PropertyGroup Condition="'$(PublishAot)' == 'true'">
<MtouchExtraArgs>marshal-managed-exceptions:disable</MtouchExtraArgs>
<MtouchNoSymbolStrip Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">True</MtouchNoSymbolStrip>
</PropertyGroup>

<PropertyGroup Condition="'$(PublishAot)' == 'false' Or '$(PublishAot)' == ''">
<MtouchExtraArgs>--marshal-managed-exceptions:unwindnativecode</MtouchExtraArgs>
</PropertyGroup>

<!--
Workaround to ensure the Sentry Cocoa SDK is present when using iOS "Hot Restart" deployments on Windows
Expand All @@ -13,7 +26,6 @@

<PropertyGroup>
<HotRestartPackageResourcesDir>$(TEMP)\Xamarin\HotRestart\Resources\</HotRestartPackageResourcesDir>
<MtouchExtraArgs Condition="'$(PublishAot)' == 'true'">--marshal-objectivec-exceptions:disable</MtouchExtraArgs>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions src/Sentry/Platforms/Cocoa/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ public static partial class SentrySdk
private static void InitSentryCocoaSdk(SentryOptions options)
{
options.LogDebug("Initializing native SDK");
// Workaround for https://github.com/xamarin/xamarin-macios/issues/15252
ObjCRuntime.Runtime.MarshalManagedException += (_, args) =>
{
args.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;
};

// Set default release and distribution
options.Release ??= GetDefaultReleaseString();
Expand Down

0 comments on commit 191776c

Please sign in to comment.