@timbre's answer makes many good points and is worth an up-vote. But it didn't answer exactly what I needed. So here's what I came up with.
See this article for how I came up with 6.0 corresponding to target SDK macOS 15
#if swift(>=5.0)
...swift code...
#else
...old approach...
#endif
#if canImport(SwiftUI, _version: "6.0") //hack to test for macOS 15 target sdk
...swift code...
...perhaps using #available if deployment sdk is older...
#else
...old approach...
#endif