What versions of Swift are supported by what versions of Xcode?

Since I've been gathering data and doing tests, I'll post my results as an updated chart in this answer:

A chart depicting the different versions of Swift as compared to their respective versions of Xcode. Last updated 2020-02-25

Awhile ago, I found out that newer versions of Xcode do not, in fact, support migrating from all older versions of Swift. I did explicitly test that Xcodes 10.2 through 11 don't support Swift 3.x and earlier, so I colored those white. I've not yet had time to test Xcode 8.3 through 10.1, but I suspect they will migrate 3.x but not 2.x or earlier; that's why there's a big "Unknown" block at the top.


Sources

  • Manual testing with this test code: https://github.com/BenLeggiero/Swift-Version-Checker
  • Xcode Release Notes
  • Swift Release Notes

This isn't a complete answer to fill all the unknown spaces in your diagram, but perhaps I can fill in some thing helpful regardless...

Swift 3.x?

When Swift 4 development got underway (and first formally announced at WWDC17), the version number of the compiler forked from that of the language. (It's much like how, say, the ANSI C standard has different versioning from the clang and GCC compilers.)

The language version number tracks source compatibility — of the language definition itself, of the standard library, and of the way that Apple platform SDKs appear in Swift. If you have "Swift 3" code, you should be able to compile it with version 3 of the Swift compiler, or any later version of the compiler when using the -swift-version 3 option.

But "Swift 3" — the language version — isn't staying fixed, either. As Swift continues to evolve, changes to the language, standard library, and SDKs that are purely additive become available to Swift 3. So, if you have a Swift 3 codebase and start working with a newer compiler, you can choose whether to convert everything to Swift 4, start using the new compiler features, or retain compatibility with older Swift 3 compilers.

This means there's a mapping of compiler versions to possible language-compatibility versions:

  • Swift language 3.2 is "Swift 3 mode" for the Swift compiler 4.0
  • Swift language 3.3 is "Swift 3 mode" for the Swift compiler 4.1
  • Swift language 3.4 is "Swift 3 mode" for the Swift compiler 4.2

There is not yet a Swift 5 (language or compiler) release, but when that happens, it'll likely allow building in -swift-version 4 mode, creating a "Swift 4.3" language version. (Assuming future Swift 4.x releases don't take those numbers first.)

I'm not aware of a single source for this answer, but you can put it together from:

  • Version Compatibility in The Swift Programming Language book
  • SE-212 Compiler Version Directive
  • WWDC17 and WWDC18 What's New in Swift talks
  • downloading various beta, current, and past Xcode versions

Version History

Some minor corrections to parts of your diagram that are further in the past:

  • Xcode 8 included two separate versions of the compiler, rather than one compiler with a -swift-version switch. Xcode 8.3 stopped including the Swift 2.3 compiler, leaving Swift 3.1 as the only supported Swift language in that version.

  • Xcode 7 / Swift 2 never supported compiling Swift 1.x code, only migrating it. Xcode 7.2 and beyond, up to the current Xcode 10 beta, still include the "Convert to Current Swift Syntax" migrator, which in theory supports migrating from any older version of Swift.

  • Xcode 6.0 through 6.2.x supported running Xcode on OS X Mavericks (10.9). Xcode 6.3 was the first to require OS X Yosemite (10.10).

Additional sources: old Xcode downloads.

Discouraged?

I'm not sure how well this label applies...

  • During the time when Xcode 8.x included the Swift 2.3 compiler, it was fully supported for building apps and submitting to the App Store. You could say that it was nonetheless "discouraged" at that time, though, in that Apple said both that it wouldn't stick around and that Swift 3.0 would be the first language version that later compilers are backward source compatible to.

  • Swift 3.2 is/was fully supported in Xcode 9 — unlike Swift 2.3 -> 3.0, there's no "get off this version before we take it away" messaging from Apple or the Swift open source project. Swift language versions 3.2, 3.3, and 3.4 are there explicitly for the reason of allowing developers to maintain "Swift 3" codebases while gaining the benefits of newer compiler and IDE releases.