Is Foundation still incomplete on Windows?

I would split your question into two parts.

URLRequest, URLSession and other types related to network requests are placed in FoundationNetworking instead of Foundation on non-Darwin platforms. This helps to strip libcurl dependency from Foundation because it’s heavy and less likely used.

sleep is not an interface of Foundation. It is exposed as a part of the C standard library (Darwin.C on Apple systems or Glibc on Linux/BSD), which is imported by Foundation. However, ucrt on Windows doesn’t expose sleep, that’s why you can’t find it by importing Foundation.

In fact, such exposure of APIs from an imported third-party library is not ideal. Some community members are working on import access control, which will introduce hiding external APIs by default, see [Pre-Pitch] Import access control: a modest proposal. If you want to use sleep, you’d better import Darwin.C or Glibc explicitly.

The open-source, Swift-based implementation of Foundation is available and under development at GitHub - apple/swift-corelibs-foundation: The Foundation Project, providing core utilities, internationalization, and OS independence. All toolchains available at Swift.org uses the open-source implementation, so you can easily check them out.

5 Likes