Build-time SDK availability check

In this thread it was brought up that there may be changes in the Swift Standard Library that are based on SDK. It's not clear what you'd check for in an canImport in this case:

#if canImport(???)
// Primary Associated Types on Collection are only declared in the iOS 16 and macOS 13 SDKs
func demo(x: some Collection<Int>) { ... }
#else
func demo<T>(x: T) where T: Collection, T.Element == Int
#endif
1 Like