Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sentry.Unity.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Unity.Android.Tests"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Unity.Native", "src\Sentry.Unity.Native\Sentry.Unity.Native.csproj", "{F291F324-D17C-4732-9E54-099D326B0929}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Unity.MacOS", "src\Sentry.Unity.MacOS\Sentry.Unity.MacOS.csproj", "{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Analyzers", "src\sentry-dotnet\src\Sentry.Analyzers\Sentry.Analyzers.csproj", "{C1798B72-5382-4C13-96F0-EAFDA28428F0}"
EndProject
Global
Expand Down Expand Up @@ -201,6 +203,18 @@ Global
{F291F324-D17C-4732-9E54-099D326B0929}.Release|x64.Build.0 = Release|Any CPU
{F291F324-D17C-4732-9E54-099D326B0929}.Release|x86.ActiveCfg = Release|Any CPU
{F291F324-D17C-4732-9E54-099D326B0929}.Release|x86.Build.0 = Release|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Debug|x64.ActiveCfg = Debug|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Debug|x64.Build.0 = Debug|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Debug|x86.ActiveCfg = Debug|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Debug|x86.Build.0 = Debug|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Release|Any CPU.Build.0 = Release|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Release|x64.ActiveCfg = Release|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Release|x64.Build.0 = Release|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Release|x86.ActiveCfg = Release|Any CPU
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F}.Release|x86.Build.0 = Release|Any CPU
{C1798B72-5382-4C13-96F0-EAFDA28428F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1798B72-5382-4C13-96F0-EAFDA28428F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1798B72-5382-4C13-96F0-EAFDA28428F0}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -233,6 +247,7 @@ Global
{35A9BDB0-253E-4753-9D47-99CE6AAA4F07} = {36979A3D-4741-4D8A-82BF-4010474388E1}
{DC954ED7-3DFA-4197-B511-202CB70AA816} = {6A85CE0A-6FE4-4190-ABEE-7E8BCFF9AF4D}
{F291F324-D17C-4732-9E54-099D326B0929} = {36979A3D-4741-4D8A-82BF-4010474388E1}
{B0C3BCDC-44F8-4DD0-B57A-6517F195C06F} = {36979A3D-4741-4D8A-82BF-4010474388E1}
{C1798B72-5382-4C13-96F0-EAFDA28428F0} = {36979A3D-4741-4D8A-82BF-4010474388E1}
EndGlobalSection
EndGlobal
87 changes: 87 additions & 0 deletions package-dev/Runtime/Sentry.Unity.MacOS.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 13 additions & 48 deletions package-dev/Runtime/SentryInitialization.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#if !UNITY_EDITOR

#if UNITY_IOS || (UNITY_STANDALONE_OSX && ENABLE_IL2CPP)
#if UNITY_IOS
#define SENTRY_NATIVE_COCOA
#endif

#if UNITY_ANDROID && ENABLE_IL2CPP
#define SENTRY_NATIVE_ANDROID
#endif

#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || UNITY_GAMECORE || UNITY_PS5
#if UNITY_STANDALONE_OSX
#define SENTRY_NATIVE_MACOS
#endif

#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_GAMECORE || UNITY_PS5
#define SENTRY_NATIVE
#endif

Expand All @@ -22,7 +26,7 @@

#endif

#if ENABLE_IL2CPP && (SENTRY_NATIVE_COCOA || SENTRY_NATIVE_ANDROID || SENTRY_NATIVE)
#if ENABLE_IL2CPP && (SENTRY_NATIVE_COCOA || SENTRY_NATIVE_ANDROID || SENTRY_NATIVE_MACOS || SENTRY_NATIVE)
#define IL2CPP_LINENUMBER_SUPPORT
#endif

Expand All @@ -35,13 +39,8 @@
using UnityEngine;
using UnityEngine.Scripting;

#if UNITY_STANDALONE_OSX
#if SENTRY_NATIVE_COCOA
using Sentry.Unity.iOS;
#endif
#if SENTRY_NATIVE
using Sentry.Unity.Native;
#endif
#if SENTRY_NATIVE_MACOS
using Sentry.Unity.MacOS;
#elif SENTRY_NATIVE_COCOA
using Sentry.Unity.iOS;
#elif SENTRY_NATIVE_ANDROID
Expand Down Expand Up @@ -88,8 +87,8 @@ private static void Init()
{
// If the SDK is not `enabled` we're closing down the native layer as well. This is especially relevant
// in a `built-time-initialization` scenario where the native SDKs self-initialize.
#if UNITY_STANDALONE_OSX
CloseMacosBackend(options);
#if SENTRY_NATIVE_MACOS
SentryNativeMacos.Close(options);
#elif SENTRY_NATIVE_COCOA
SentryNativeCocoa.Close(options);
#elif SENTRY_NATIVE_ANDROID
Expand All @@ -103,8 +102,8 @@ private static void SetUpPlatformServices()
SentryPlatformServices.CollectMainThreadData();
SentryPlatformServices.UnityInfo = new SentryUnityInfo();

#if UNITY_STANDALONE_OSX
SentryPlatformServices.PlatformConfiguration = ConfigureMacosBackend;
#if SENTRY_NATIVE_MACOS
SentryPlatformServices.PlatformConfiguration = SentryNativeMacos.Configure;
#elif SENTRY_NATIVE_COCOA
SentryPlatformServices.PlatformConfiguration = SentryNativeCocoa.Configure;
#elif SENTRY_NATIVE_ANDROID
Expand All @@ -118,40 +117,6 @@ private static void SetUpPlatformServices()
#endif
}

#if UNITY_STANDALONE_OSX
private static void ConfigureMacosBackend(SentryUnityOptions options)
{
#if SENTRY_NATIVE
if (options.Experimental.MacosBackend == MacosBackend.Native)
{
SentryNative.Configure(options);
return;
}
#endif
#if SENTRY_NATIVE_COCOA
SentryNativeCocoa.Configure(options);
#else
options.DiagnosticLogger?.LogWarning(
"MacosBackend is set to Cocoa, but Cocoa requires IL2CPP. " +
"Native crash reporting is disabled. Set MacosBackend to Native or enable IL2CPP.");
#endif
}

private static void CloseMacosBackend(SentryUnityOptions options)
{
if (options is null)
{
return;
}
#if SENTRY_NATIVE_COCOA
if (options.Experimental.MacosBackend == MacosBackend.Cocoa)
{
SentryNativeCocoa.Close(options);
}
#endif
// Native: nothing to do — SentryNative registers its own close callback at Configure time.
}
#endif
}

public class SentryUnityInfo : ISentryUnityInfo
Expand Down
12 changes: 12 additions & 0 deletions src/Sentry.Unity.MacOS/Sentry.Unity.MacOS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutDir>$(PackageRuntimePath)</OutDir>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../sentry-dotnet/src/Sentry/Sentry.csproj" Private="false" />
<ProjectReference Include="../Sentry.Unity/Sentry.Unity.csproj" Private="false" />
<ProjectReference Include="../Sentry.Unity.iOS/Sentry.Unity.iOS.csproj" Private="false" />
<ProjectReference Include="../Sentry.Unity.Native/Sentry.Unity.Native.csproj" Private="false" />
</ItemGroup>
</Project>
42 changes: 42 additions & 0 deletions src/Sentry.Unity.MacOS/SentryNativeMacos.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Sentry.Extensibility;
using Sentry.Unity.iOS;
using Sentry.Unity.Native;
using Sentry.Unity.NativeUtils;

namespace Sentry.Unity.MacOS;

public static class SentryNativeMacos
{
public static void Configure(SentryUnityOptions options)
{
if (options.Experimental.MacosBackend == MacosBackend.Native)
{
SentryNative.Configure(options);
return;
}

if (!SentryPlatformServices.UnityInfo.IL2CPP)
{
options.DiagnosticLogger?.LogWarning(
"Cocoa backend requires IL2CPP on macOS. Native crash reporting is disabled. " +
"Set macOS Backend to Native or enable IL2CPP.");
return;
}

SentryNativeCocoa.Configure(options);
}

public static void Close(SentryUnityOptions options)
{
if (options is null)
{
return;
}

if (options.Experimental.MacosBackend == MacosBackend.Cocoa
&& SentryPlatformServices.UnityInfo.IL2CPP)
{
SentryNativeCocoa.Close(options);
}
}
}
4 changes: 4 additions & 0 deletions test/Scripts.Tests/package-release.zip.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ Runtime/Sentry.Unity.iOS.dll
Runtime/Sentry.Unity.iOS.dll.meta
Runtime/Sentry.Unity.iOS.pdb
Runtime/Sentry.Unity.iOS.pdb.meta
Runtime/Sentry.Unity.MacOS.dll
Runtime/Sentry.Unity.MacOS.dll.meta
Runtime/Sentry.Unity.MacOS.pdb
Runtime/Sentry.Unity.MacOS.pdb.meta
Runtime/Sentry.Unity.Native.dll
Runtime/Sentry.Unity.Native.dll.meta
Runtime/Sentry.Unity.Native.pdb
Expand Down
Loading