What is the difference between the swift 5 language mode and the actual swift versions like 5.5, 5.7 etc

I read how there are different language features between the swift 5, 4.2, and 4 language modes, but what confuses me is, how do the minor versions of swift fit into these language modes? if we use the swift 5 language mode for both swift 5.0 code and swift 5.5 code, does this mean that there are no new language features between 5.0 and 5.5?

If yes, then are we saying that the Swift Concurrency (introduced in swift 5.5) is not "language features" but are "functional features" as part of the standard library? these distinctions puzzle me...

What exactly is a "language feature"?

Language modes gate source-breaking changes to the language. They serve Swift’s source stability guarantee (in effect since Swift 4.0 IIRC), which says that existing code will continue to compile under new compiler versions.*

* With minor exceptions, e.g. for newly added keywords. For instance, if your Swift 5.4 project contained a function named func await(_ f: () -> Void), switching to the Swift 5.5 compiler would likely be a breaking change, but these instances are so rare that they're considered acceptable (and unavoidable to some degree).

New compiler versions (5.5, 5.6 etc.) can still (and do) add new features as long as they're not source-breaking. For example, Swift Concurrency introduced async functions and the await syntax. Since these were additive changes (aside from the minor exception mentioned above), they could be added without introducing a new language mode.


The major change in the Swift 6 language mode is the enforcement of data race safety. It's gated behind a new language mode because it can break existing code (in the sense that code that compiled in Swift 5 mode may no longer compile in Swift 6 mode, regardless if the code actually contains data races or not).

When you use the Swift 6.0 compiler in Swift 5 language mode, you can still use all the Swift concurrency features (because they're additive) except strict data race safety enforcement (in other words, you get warnings instead of errors).

Similarly, the Swift 6 mode activates a bunch of other source-breaking changes that you'd have to enable one-by-one in Swift 5 mode with an upcoming feature flag. See @James_Dempsey's article Swift.org - Using Upcoming Feature Flags for more on this.

11 Likes