Where is the Swift 3.2 binary?

Xcode 9 Beta allows swapping between Swift 3.2 and Swift 4 in build settings. If I navigate to


/Applications/Xcode_9_beta_2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


the Swift binary reports its version as:


Apple Swift version 4.0 (swiftlang-900.0.45.6 clang-900.0.26)


I've searched everywhere through the other Xcode.app folders, but can't find any Swift 3.2 binary. Where is it or how does Xcode 9 swap between Swift 4 and Swift 3.2 with only one binary that is reported as Swift 4?

Accepted Reply

This thread has been deleted

I think the OP is asking how Swift 4 (in Xcode 9) is able to compile not-yet-converted 3.2 code without there being a separate Swift 3.2 compiler executable.


The answer is that 3.2 is a compilation mode within the Swift 4 compiler. In effect, Swift 4 recognizes both forms of the language. If it's running in version 4 mode, it will offer fix-its to convert 3.2 constructions that are no longer valid in 4. If it's running in version 3.2 mode, it disallows some version 4 syntax, but allows pretty much anything new in version 4 that's purely additive — that couldn't have meant something in 3.x code previously.


It does all this to try to minimize the impact of converting (or not converting) existing code to version 4 standard.


The mode selection is made via an Xcode build setting, and I assume there's a command-line argument that does the same thing. I don't know what it is, but I guess you could look in an Xcode build transcript (for example) to find out.

Replies

>Where is it or how does Xcode 9 swap between Swift 4 and Swift 3.2 with only one binary that is reported as Swift 4?


Xcode 9/Swift 4 performs 'migration' from 3.2, providing quasi-support as far as that process is involved - no need to toggle to 3.2/support lower than Swift 4 at that point.


See the release notes for details:

https://download.developer.apple.com/Developer_Tools/Xcode_9_beta_3/Release_Notes_for_Xcode_9_beta_3.pdf