40

I develop apps in Swift for a living. I enjoy the language and follow it as closely as I can. Yet, still, certain facts slip through, whether by me being blindsided, or by Apple being very quiet about them.

Today, I discovered that Swift 3.3 and 3.4 exist. I was under the assumption that 3.2 was the last version of 3, for use in migrating to 4, 4.2, and 5. This misconception is mostly due to the fact that Swift.org, the official Git repo, and Xcode Release Notes don't mention them at all.

So, I assume these are also transitional, but I've no idea what IDE or compiler they appear in, or what caveats they come with. Below is a table which sums up my knowledge:

The below table is outdated, provided for context so the question makes sense. I've posted an updated version of this table in an answer below.

A complex table with many versions of Swift and Xcode as the axes, and the support versions as the content

What goes in the purple spaces? Specifically for the 3.3 and 3.4 rows, but if you know the other ones, that would help too!

Authoritative sources would also be awesome.


Possible answers to the primary question are as follows:

  1. Swift 3.3 was only in Xcode 9.3 beta and never became public; Swift 3.4 was only in Xcode 9.3 - 9.4
  2. Swift 3.3 was only supported in Xcode 9.3; Swift 3.4 was supported in Xcode 9.3.1 and 9.4
  3. Swift 3.3 was supported in Xcode 9.3 and 9.3.1; Swift 3.4 was only supported in Xcode 9.4
  4. Swift 3.3 was supported in Xcode versions 9.3 though 9.4; Swift 3.4 was only supported in an Xcode 10 beta.

I don't think there's another possibility. Do let me know if I'm off-base, though.

19
  • 5
    Your chart is delightful, but I don't understand why you need to ask about this. Surely the way to find out what version of Swift is included in a version of Xcode is to download that version of Xcode and see.
    – matt
    Commented Jul 17, 2018 at 17:15
  • 7
    Worth noting that Swift 3.2, 3.3 & 3.4 are pseudo versions – they solely exist to represent the Swift 4.0, 4.1 and 4.2 compilers running in Swift 3 compatibility mode respectively. There's a handy table in github.com/apple/swift-evolution/blob/master/proposals/… that maps compiler to language version per compatibility mode (note that rows for 5.0 and 5.1 are no longer accurate as the version bumping ceased with the implementation of the proposal).
    – Hamish
    Commented Jul 17, 2018 at 17:29
  • 1
    "Do you have a methodology that could extract it?" Yes, I do. And so do you. For example: hackingwithswift.com/example-code/language/… It is not difficult to write a little code snippet that uses that to tell you what Swift version we were compiled under.
    – matt
    Commented Jul 17, 2018 at 19:14
  • 1
    The compiler version can be obtained from running xcrun swift --version (you can use xcode-select to select the the version of command-line tools, or change it from within Xcode's preferences under the "Locations" tab).
    – Hamish
    Commented Jul 17, 2018 at 21:23
  • 2
    Worth noting that Wikipedia has a table of Swift compiler versions for Xcode versions, which might be useful: en.wikipedia.org/wiki/Xcode#Toolchain_versions
    – Hamish
    Commented Jul 17, 2018 at 21:26

2 Answers 2

73

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

12
  • 1
    @ravemir Like I mentioned in my previous comment, those aren't the same Swift as the similarly- (or identically-) numbered ones which were in previous versions of Xcode; they are actually the backend of the newest Swift version which that version of Xcode supports, but with the older Swift syntax (e.g. Xcode 10.2 supports Swift 4.1.50, which is Swift 5.0.1 with Swift 4.1.x syntax). Because of this oddness, I recommend you just use the newest Swift version which that version of Xcode supports; it's not that different.
    – Ky -
    Commented Sep 19, 2019 at 15:23
  • 1
    Please accompany any downvotes with a comment explaining how I can provide better answers from now on 🙂
    – Ky -
    Commented Oct 18, 2019 at 18:20
  • 1
    Unfortunately I can't upvote twice but thank you for keeping this maintained.
    – matt
    Commented Jan 23, 2020 at 18:13
  • 1
    @Kymer aside from testing myself, I do also always look at the Xcode release notes and Swift release notes
    – Ky -
    Commented May 29, 2020 at 20:17
  • 1
    This will be the SO.com question that affected my work the least, but that I love the most.
    – benc
    Commented Oct 5, 2021 at 2:14
7
+100

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 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.

4
  • This is amazing, thank you for the very thorough answer! I'll definitely be able to make my chart more accurate. Just a few questions: Primarily... what do I do in the purple area for Swifts 3.3-3.4 / Xcodes 9.3-9.4? Also, could Xcode 7.x migrate Swift 1.0 to 2.x, or just 1.2 to 2.x?
    – Ky -
    Commented Jul 17, 2018 at 20:07
  • 1
    AFAIK the migrator doesn't know for sure what language version your project currently uses — it just knows what syntax patterns are no longer current and how to fix them. (At least, this was certainly the case in Xcode 7. Since Swift 3 / Xcode 8 your project contains at least some "intended Swift version" info, but it's not clear there's enough there to help the migrator with everything it needs to.)
    – rickster
    Commented Jul 17, 2018 at 20:51
  • I've taken all your advice to heart and made an updated chart in my answer. Thank you so much!
    – Ky -
    Commented Oct 15, 2018 at 15:49
  • 1
    Since the chart I posted seems to be helping people very well, I'll mark it as the accepted answer (mostly for Googlers). Because your answer got me on-track to figuring it out, I'll give it a bounty 😁
    – Ky -
    Commented Nov 26, 2019 at 5:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.