getsentry / sentry-xamarin

Sentry for Xamarin Native and Xamarin.Forms
https://docs.sentry.io/platforms/dotnet/guides/xamarin/
44 stars 11 forks source link

Added Xamarin.Mac support #138

Closed jonlipsky closed 1 year ago

jonlipsky commented 1 year ago

Session logging is not implemented for Xamarin.Mac so an additional constant was added (LIFECYCLE_PROCESSOR) to for iOS, Android and UWP that do have that functionality. Previously, NATIVE_PROCESSOR was an indication that there were native implementations for both session logging and event processing.

Note 1: The same DSN that was used in the other samples was used.

Note 2: Something similar should be implemented for the Sentry.Maui project for the "net7.0-macos" framework as well.

bruno-garcia commented 1 year ago

I'm fine adding support here fwiw. Just need to get tests to pass

Note 2: Something similar should be implemented for the Sentry.Maui project for the "net7.0-macos" framework as well.

What part specifically you mean? for MAUI we have already the device info for example. And native crash support even

jonlipsky commented 1 year ago

What part specifically you mean? for MAUI we have already the device info for example. And native crash support even

In Sentry.Maui, you are only building for MacCatalyst, not Mac (AppKit). You're missing a TargetFramework.

image

net6-macos is the missing TargetFramework.

lucas-zimerman commented 1 year ago

Hi and thank you for the PR!

A few notes from the build errors since you can't see the logs (I suppose) MacOS is complaining with

  MMP : error MM0074: Xamarin.Mac 8.12.0 does not support a deployment target of 13.1 for macOS (the maximum is 12.3). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of Xamarin.Mac. [/Users/runner/work/sentry-xamarin/sentry-xamarin/Samples/Sample.Xamarin.Mac/Sample.Xamarin.Mac.csproj]

On Windows:

  D:\a\sentry-xamarin\sentry-xamarin\Samples\Sample.Xamarin.Mac\SampleView.cs(54,27): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [D:\a\sentry-xamarin\sentry-xamarin\Samples\Sample.Xamarin.Mac\Sample.Xamarin.Mac.csproj]
  D:\a\sentry-xamarin\sentry-xamarin\Samples\Sample.Xamarin.Mac\SampleView.cs(54,17): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [D:\a\sentry-xamarin\sentry-xamarin\Samples\Sample.Xamarin.Mac\Sample.Xamarin.Mac.csproj]
bruno-garcia commented 1 year ago

What part specifically you mean? for MAUI we have already the device info for example. And native crash support even

In Sentry.Maui, you are only building for MacCatalyst, not Mac (AppKit). You're missing a TargetFramework.

image

net6-macos is the missing TargetFramework.

On their docs they mention "through Mac Catalyst": https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms

What's the benefit/goal/tradeoff of supporting also netx.x-macos ? We could continue this on a new issue on the https://github.com/getsentry/sentry-dotnet repo. Mind creating a ticket there please?

jonlipsky commented 1 year ago

What's the benefit/goal/tradeoff of supporting also netx.x-macos ?

@bruno-garcia If you want to write a Mac .NET app that uses AppKit, as opposed the Catalyst/UIKit API's, then you need to target netX-macos. (netx-macos, is essentially the latest version of Xamarin.Mac).

MAUI doesn't support an AppKit backend; however like with Xamarin.iOS and Xamarin.Mac, the majority of the code that Sentry would need would be shared, thus it's probably the best place to add it.

bruno-garcia commented 1 year ago

What's the benefit/goal/tradeoff of supporting also netx.x-macos ?

@bruno-garcia If you want to write a Mac .NET app that uses AppKit, as opposed the Catalyst/UIKit API's, then you need to target netX-macos. (netx-macos, is essentially the latest version of Xamarin.Mac).

MAUI doesn't support an AppKit backend; however like with Xamarin.iOS and Xamarin.Mac, the majority of the code that Sentry would need would be shared, thus it's probably the best place to add it.

Fair so we're talking about AppKit (Native Mac app with .NET) that targets netX.Y-macos which is .NET Core. I'd be OK adding support on sentry-dotnet for it if @bitsandfoxes agrees

jonlipsky commented 1 year ago

Fair so we're talking about AppKit (Native Mac app with .NET) that targets netX.Y-macos which is .NET Core. I'd be OK adding support on sentry-dotnet for it if @bitsandfoxes agrees

Thanks!

Also keep in mind there are developers, like myself, that do iOS and Android development that don't use MAUI. For example, my iOS apps target net7-ios; however, they don't reference or use MAUI.

bruno-garcia commented 9 months ago

Fair so we're talking about AppKit (Native Mac app with .NET) that targets netX.Y-macos which is .NET Core. I'd be OK adding support on sentry-dotnet for it if @bitsandfoxes agrees

Thanks!

Also keep in mind there are developers, like myself, that do iOS and Android development that don't use MAUI. For example, my iOS apps target net7-ios; however, they don't reference or use MAUI.

That's fair. Sentry itself uses net7.0-android for Symbol Collector. Still benefits of support for Portable PDB to get line numbers in release builds, for example. So we're keen to get the base mobile support in the core SDK. And any MAUI specific only in Sentry.Maui.