Swift reviews SE-0554 deployment-target conditionals
A proposed #if on minimum OS versions would help shared libraries pick types at compile time, while core engineers call the need a deeper language gap.
Swift is reviewing SE-0554, which would add conditional compilation based on a module’s deployment target. The change would let shared source select declarations and concrete storage types according to the minimum OS version being compiled for, something runtime availability checks cannot do for stored properties or enum cases.
Prototype toolchains with the feature are available on macOS and Windows while the review runs through 12 October 2026. The proposal’s value is clearest outside ordinary Swift Package Manager builds. Libraries compiled under Bazel, CMake, or other systems often share sources across different minimum targets; a compiler-supported condition gives them a uniform name instead of ad-hoc define flags.
Under current SwiftPM rules the feature is less transformative. A package module still takes its deployment target from its own manifest platforms list, so the new condition largely mirrors what the package already declared. Franz Busch argued that real ecosystem payoff would come only if the root product’s target propagated into dependencies, letting packages adopt newer types without a major version bump. Responders noted that SE-0554 deliberately leaves that build-system policy alone.
John McCall of the core team went further on the language design. Libraries, he wrote, should limit the releases they support but not set the deployment target; that setting belongs to the final product and should flow downward. Deployment-target conditionals would then become useful package tooling. Even so, he said he cannot help but feel that every use of the feature is a language failure: availability exists so code can take the best API present at runtime, while compile-time deployment checks force the worst common API. The underlying constraint (unavailable stored types inside structs and enums) is something Swift’s dynamic layout could address more directly. He sketched a possible fallback-struct construct with availability-gated storage options; others suggested lifting availability limits on enum payloads as a nearer-term alternative when modest runtime overhead is acceptable.
McCall also flagged a diagnostics subtlety: the condition would have to follow the user-facing diagnostics target rather than any tighter code-generation target used for fat-binary slices, limiting how aggressively it can select the newest available feature.