Skip to content

Instantly share code, notes, and snippets.

@keith
Last active May 6, 2021 00:47
Show Gist options
  • Save keith/3f01e1c9b763e9aceb70411927a0c42c to your computer and use it in GitHub Desktop.
Save keith/3f01e1c9b763e9aceb70411927a0c42c to your computer and use it in GitHub Desktop.
The matrix of Xcode build settings to compiler flags for Swift memory exclusivity
  • Compiler flag: -enforce-exclusivity=<value>
  • Build setting: SWIFT_ENFORCE_EXCLUSIVE_ACCESS

Xcode 10.1 & Swift 4.2

  • Compiler default for non optimized builds if you pass no argument is the same as if you passed checked
  • Compiler default for optimized builds if you pass no argument is the same as if you passed unchecked
Configuration Compiler Flag Value Build Setting Description Build Setting Value Notes
Debug checked Full Enforcement (Run-time Checks in All Builds) on
Debug checked Full Enforcement (Run-time Checks in Debug Builds Only) debug-only default
Debug unchecked Compile-time Enforcement compile-time
Debug none No Enforcement none
Release checked Full Enforcement (Run-time Checks in All Builds) on
Release no flag passed Full Enforcement (Run-time Checks in Debug Builds Only) debug-only default
Release unchecked Compile-time Enforcement compile-time
Release none No Enforcement none

Xcode 10.2 (beta 3) & Swift 5

  • Compiler default if you pass no argument is the same as if you passed checked
Configuration Compiler Flag Value Build Setting Description Build Setting Value Notes
Debug checked Full Enforcement (Run-time Checks in All Builds) on default
Debug checked Full Enforcement (Run-time Checks in Debug Builds Only) debug-only
Debug unchecked Compile-time Enforcement Only off
Release checked Full Enforcement (Run-time Checks in All Builds) on default
Release unchecked Full Enforcement (Run-time Checks in Debug Builds Only) debug-only
Release unchecked Compile-time Enforcement Only off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment