dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22k stars 1.72k forks source link

Essentials support for net6.0-macos #6333

Open chucker opened 2 years ago

chucker commented 2 years ago

Description

MAUI Essentials is the quasi-successor to Xamarin Essentials, and like its predecessor provides useful APIs outside of MAUI itself as well, such as the Preferences abstraction; hence the <UsingMauiEssentials>true</UsingMauiEssentials> property.

Xamarin Essentials also worked with Xamarin.Mac. For example, Preferences simply mapped to macOS's NSUserDefaults. I would like the equivalent support for net6.0-macos.

Public API Changes

(not applicable — bindings already exist in https://github.com/xamarin/xamarin-macios; the project would add net6.0-macos as an additional TFM)

Intended Use-Case

I have existing apps that currently target Xamarin.Mac (AppKit) and would migrate to net6.0-macos, and without this feature, I wouldn't be able to swap Xamarin Essentials for Maui Essentials.

drasticactions commented 2 years ago

IMO since MAUI itself doesn't support net6.0-macos, adding Essentials support to it wouldn't make sense here unless MAUI itself supports it, since the two complements each other.

Of course, you can use MAUI Essentials outside of MAUI proper, but in that case, maybe it would more useful for the Community Toolkit? The interfaces are in MAUI itself, and the Toolkit (or separate library) can host the implementation. And if net6.0-macos gets added to MAUI itself, then that work could be merged back into this repo.

GalaxiaGuy commented 2 years ago

I don't believe Essentials needs to be limited to the platforms Maui supports. Xamarin Essentials has pretty wide use beyond Forms and I don't see why apps that don't currently use Forms should need to suddenly take Maui as a dependency.

Community toolkit would not be the place to put it since it's at the wrong end of the dependency chain:

Community toolkit -> Maui -> Essentials

As a related precedent Microsoft.Maui.Graphics has wider platform support than Maui.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Peru-S commented 1 year ago

Hello there, There is a typo in both this thread and in https://devblogs.microsoft.com/xamarin/xamarin-essentials-1-7-and-introducing-net-maui-essentials/ ; which is not present in (the newer?) https://learn.microsoft.com/en-us/dotnet/maui/migration/native-essentials?tabs=ios#modify-your-project-file . One says UsingMauiEssentials which does not pop an error; other says UseMauiEssentials which is the correct one. Of course, gh code search results in confusing uses of both - please help fix the docs/code, the migration to net7.0-sdk-style is hard enough, let alone having to deal with the internal inconsistencies :( I stumbled into the 'right' version by accident, no idea how.

Also, having a safe deprecation warning in Xamarin.Essentials / upgrade-assistant gently lean into Maui Essentials would be even nicer (instead of Xamarin.Essentials failing randomly during runtime when using inside the new .net sdk style / net7.0 projects).

maxkatz6 commented 9 months ago

@mattleibow hello! Would a PR be reviewed/accepted, if I reintroduce macOS TFM support for the Essentials package?

From what I have checked, my plan is following:

  1. Add new MauiEssentialsPlatforms msbuild property similarly to how it was done with MauiGraphicsPlatforms. And include macOS there depending on IncludeMacOSTargetFrameworks.
  2. Include macOS implementation files back into the project.
  3. Add macOS PublicAPI files with all APIs as unshipped.
  4. Go through macOS implementations and make sure they compile with .NET macOS APIs (as there are quite some differences from Xamarin APIs). And replace some obsolete APIs with newer ones.
  5. Essentials.DeviceTests looks a bit tricky, but it seems macOS should also be added there. At least some of the APIs should be covered.

Let me know if I am missing any other steps.

I have started these changes in this branch: https://github.com/maxkatz6/maui/tree/macos-essentials Still doesn't compile