When thinking about all of these it is critical to consider the distinction between compile time and run time. The above code will compile when compiled on any system that has an SDK new enough to contain the DateInterval
type in the SDK. This will have shipped with the Xcode that shipped with macOS 10.12, or any later Xcode.
The compiled artefact will run on macOS 10.11 (if your minimum deployment target is configured to include 10.11), but the DateInterval
code will not be executed. It will still exist in the binary, but you will have been required to introduce runtime checks that prevent that code from ever running as part of the build process.
This is an important thing to note: the minimum SDK version you require at compile time is distinct from the minimum deployment target you set for runtime. The first constrains the build system, the second constrains the use system. The minimum deployment target is a configuration of the project, and can never be higher than the minimum SDK version you require. The minimum SDK version is implicit, and is derived from the highest of:
- the minimum deployment target
- all
@available
orif #available
guards in your program
Correct.