-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IsMacCatalyst() and IsMacCatalystVersionAtLeast() to System.Runtime #47768
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Versioning on Mac Catalyst is somewhat complex, because there are two versions in effect: the macOS version the app is running (or targeting), and the equivalent iOS version of the Mac Catalyst API. Unfortunately Apple decided to use the macOS version in some places, and the iOS version in other places. For the Xamarin parts of Mac Catalyst (API bindings), we decided to use the iOS version for API version checks (xamarin/xamarin-macios#10453), because this is the version that Apple uses in Objective-C/Swift, and the version they use in their documentation. Unfortunately it's not the version their version API ( The end result is that we had to special-case the API we expose for version checks to handle Mac Catalyst versions (rolfbjarne/xamarin-macios@9314bb5). I believe |
@rolfbjarne That's valuable info RE the implementation details. Does it change anything about the API added to the System.Runtime reference assembly (i.e. |
src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs is where the actual implementation is happening, I'd welcome suggestions there |
No, it doesn't change the public API in any way, it's an implementation detail. Should I open a new issue about it? |
Maybe just move the discussion to the PR for now? Unless it gets merged with "wrong" version detection, then a new issue is absolutely correct |
namespace System.Diagnostics
{
public partial class OperatingSystem
{
public static bool IsMacCatalyst();
public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0);
}
} |
Background and Motivation
As per the header, all changes to src/libraries/System.Runtime/ref/System.Runtime.cs are subject to API review. This is a minimal change to class OperatingSystem to add checks for Mac Catalyst, directly copying the existing behaviour of
IsTvOS()
andIsTvOSVersionAtLeast
Roughly speaking, Mac Catalyst exposes the iOS API subset for use on macOS, allowing for source (but not binary) compatibility with iOS/iPad apps. A number of the default apps in recent macOS are actually Catalyst apps.
Ref: #47517
Proposed API
Usage Examples
Right now, my main usage is in correctly gating which tests are run specifically against the correct platform, i.e.
Alternative Designs
You could argue that adding one bool-return function per OS isn't very scalable, but that ship already sailed a long time ago I think.
The text was updated successfully, but these errors were encountered: