Skip to content

Instantly share code, notes, and snippets.

@erica
Last active March 14, 2016 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erica/5a344b12bd989f6395c2 to your computer and use it in GitHub Desktop.
Save erica/5a344b12bd989f6395c2 to your computer and use it in GitHub Desktop.

Introducing Build Configuration Tests for Platform Conditions

  • Proposal: SE-00XX
  • Author(s): Erica Sadun
  • Status: TBD
  • Review manager: TBD

Introduction

This proposal introduces configuration test to differentiate platform conditions.

This proposal was discussed on-list in the Introducing Build Configuration Tests for Platform Conditions.

Motivation

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.

Detail Design

This proposal adds the following build configuration tests:

  • #if endian(big)
  • #if endian(little)
  • #if bitwidth(32)
  • #if bitwidth(64)

Current Art

Swift currently supports the following configuration tests:

  • The literals true and false
  • The os() function that tests for OSX, iOS, watchOS, tvOS, Linux, Windows, and FreeBSD
  • The arch() function that tests for x86_64, arm, arm64, i386, powerpc64, and powerpc64le
  • The swift() function that tests for specific Swift language releases, e.g. swift(>=2.2)

Alternatives Considered

There are no alternatives considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment