- Proposal: SE-00XX
- Author(s): Erica Sadun
- Status: TBD
- Review manager: TBD
This proposal introduces configuration test to differentiate platform conditions.
This proposal was discussed on-list in the Introducing Build Configuration Tests for Platform Conditions.
Testing for platform conditions is a typical developer task. Although some built-in
features like CFByteOrderGetCurrent
exist, it seems a natural match to Swift to
introduce build configurations specific to common platform conditions.
This proposal adds the following build configuration tests:
#if endian(big)
#if endian(little)
#if bitwidth(32)
#if bitwidth(64)
Swift currently supports the following configuration tests:
- The literals
true
andfalse
- The
os()
function that tests forOSX, iOS, watchOS, tvOS, Linux, Windows, and FreeBSD
- The
arch()
function that tests forx86_64, arm, arm64, i386, powerpc64, and powerpc64le
- The
swift()
function that tests for specific Swift language releases, e.g.swift(>=2.2)
There are no alternatives considered.