Skip to content

[API Proposal]: Make IsApplePlatform public #113262

Description

@makazeu

Background and motivation

When people want check if current application is running on Apple platforms, like macOS, iOS, watchOS, tvOS, they probably need to call OperatingSystem.IsMacOS() and OperatingSystem.IsIOS(), etc.

Perhaps we should provide a public method IsApplePlatform() .

We already have such internal method:

internal static bool IsApplePlatform() =>
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
true;
#else
false;
#endif

API Proposal

        [NonVersionable]
        public static bool IsApplePlatform() =>
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_WATCHOS
            true;
#else
            false;
#endif

API Usage

if (OperatingSystem.IsApplePlatform()) 
{
     Console.WriteLine("Hello World from Cupertino, California");
}

Alternative Designs

No response

Risks

No response

Activity

  1. added
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on Mar 7, 2025
  2. ghost added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Mar 7, 2025
  3. added and removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Mar 7, 2025
  4. dotnet-policy-service commented on Mar 7, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-runtime
    See info in area-owners.md if you want to be subscribed.

  5. added
    in-prThere is an active PR which will close this issue when it is merged
    on Mar 7, 2025
  6. kleisauke commented on Mar 25, 2025

    @kleisauke

    This could be useful to select the correct library extension (i.e. *.dylib) in a DllImportResolver callback. See for example commit kleisauke/net-vips@0fa851c.

  7. jeffhandley commented on Jul 26, 2025

    @jeffhandley
    Member

    @lewing / @steveisok -- What are your thoughts on this? Any risk you can see in exposing this as a public property?

  8. added
    needs-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
    and removed
    untriagedNew issue has not been triaged by the area owner
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 26, 2025
  9. added this to the Future milestone on Jul 26, 2025
  10. steveisok commented on Jul 26, 2025

    @steveisok
    Member

    @lewing / @steveisok -- What are your thoughts on this? Any risk you can see in exposing this as a public property?

    I don't see much risk. It's a conveinence when dealing with all the apple configurations.

  11. added
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    and removed
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    needs-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
    on Jul 11, 2026
  12. bartonjs commented on Sep 8, 2026

    @bartonjs
    Member

    Video

    Looks good as proposed

    namespace System;
    
    public partial class OperatingSystem
    {
        public static bool IsApplePlatform();
    }
  13. added
    api-approvedAPI was approved in API review, it can be implemented
    and removed
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions