Skip to content

Commit 191776c

Browse files
committed
InitSentryCocoaSdk - Native AOT | set marshal-managed-exceptions at compilation instead of runtime
1 parent fa4d434 commit 191776c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Sentry.Bindings.Cocoa/buildTransitive/Sentry.Bindings.Cocoa.targets

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
<Project>
2+
3+
<!--
4+
Workaround for https://github.com/xamarin/xamarin-macios/issues/15252
5+
ensuring that Native AOT compile code does not get the wrong marshal-managed-exceptions
6+
-->
7+
<PropertyGroup Condition="'$(PublishAot)' == 'true'">
8+
<MtouchExtraArgs>marshal-managed-exceptions:disable</MtouchExtraArgs>
9+
<MtouchNoSymbolStrip Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">True</MtouchNoSymbolStrip>
10+
</PropertyGroup>
11+
12+
<PropertyGroup Condition="'$(PublishAot)' == 'false' Or '$(PublishAot)' == ''">
13+
<MtouchExtraArgs>--marshal-managed-exceptions:unwindnativecode</MtouchExtraArgs>
14+
</PropertyGroup>
215

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

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

1931
<ItemGroup>

src/Sentry/Platforms/Cocoa/SentrySdk.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ public static partial class SentrySdk
1010
private static void InitSentryCocoaSdk(SentryOptions options)
1111
{
1212
options.LogDebug("Initializing native SDK");
13-
// Workaround for https://github.com/xamarin/xamarin-macios/issues/15252
14-
ObjCRuntime.Runtime.MarshalManagedException += (_, args) =>
15-
{
16-
args.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;
17-
};
1813

1914
// Set default release and distribution
2015
options.Release ??= GetDefaultReleaseString();

0 commit comments

Comments
 (0)