<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>294412</bug_id>
          
          <creation_ts>2025-06-12 15:25:17 -0700</creation_ts>
          <short_desc>[Swift] Availability versions are inaccurate in downlevels</short_desc>
          <delta_ts>2026-02-13 16:56:03 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Elliott Williams">emw</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>richard_robinson2</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2123377</commentid>
    <comment_count>0</comment_count>
    <who name="Elliott Williams">emw</who>
    <bug_when>2025-06-12 15:25:17 -0700</bug_when>
    <thetext>In ObjC, `postprocess-headers-rule` strips out API_AVAILABLE attributes at build time, so that downlevel builds of Safari are not restricted from accessing WebKit API that shipped in more recent OS versions. While https://bugs.webkit.org/show_bug.cgi?id=294361 addresses _TBA_ versions being usable by downlevel builds, it doesn&apos;t propose a fix for _shipped_ APIs become inaccessible in Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2124775</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-06-19 15:26:12 -0700</bug_when>
    <thetext>&lt;rdar://problem/153851259&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2124782</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2025-06-19 16:13:51 -0700</bug_when>
    <thetext>&gt; downlevel builds of Safari are not restricted from accessing WebKit API that shipped in more recent OS versions

This sounds like correct behavior to me, Safari should be able to use new APIs from aligned WebKit builds, even when deploying to an OS where ethernet system WebKit doesn&apos;t have them.

Sometimes new APIs only work on newer OSes, but we&apos;d need a different kind of annotation for this, if it&apos;s actually an important problem to solve (I&apos;d expect that such targeted API use would be cleanly conditionalized at caller site already).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2181573</commentid>
    <comment_count>3</comment_count>
    <who name="Elliott Williams">emw</who>
    <bug_when>2026-02-13 16:49:39 -0800</bug_when>
    <thetext>Right. In ObjC, one can write

    -(void)myAPIThatHasAlreadyShipped WK_API_AVAILABLE(macOS(26.0), iOS(26.0));

and because it&apos;s using WK_API_AVAILABLE, we strip the annotation entirely when building downlevels. So a downlevel targeting macOS 15 would still be able to call this method.

In Swift, we have no WK_API_AVAILABLE-esque macro that we can turn off at build time. One would write

    @available(macOS 26.0, iOS 26.0, *)
    func myAPIThatHasAlreadyShipped()

and it would be disallowed in the same downlevel build.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2181577</commentid>
    <comment_count>4</comment_count>
    <who name="Elliott Williams">emw</who>
    <bug_when>2026-02-13 16:54:34 -0800</bug_when>
    <thetext>One solution could be to come up with custom availability macros that we can retarget at build time. For example:

    @available(WebKit26_0)
    func myAPIThatHasAlreadyShipped()

where we compile with:

    swiftc ... -define-availability &apos;WebKit26_0 : macOS 26.0, iOS 26.0, visionOS 26.0&apos;

In that downlevel build for Sequoia we&apos;d compile with:

    swiftc ... -define-availability &apos;WebKit26_0 : macOS 15.4, iOS 15.4&apos;

This would also have the advantage of saving everyone some typing by consolidating the different platforms into one availability macro.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2181582</commentid>
    <comment_count>5</comment_count>
    <who name="Elliott Williams">emw</who>
    <bug_when>2026-02-13 16:56:03 -0800</bug_when>
    <thetext>And a custom availability macro would make it easier to implement https://bugs.webkit.org/show_bug.cgi?id=280912, which entails adding watchOS and tvOS availabilities to everything.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>