What is the “Swift Language Version” Xcode setting for? Because it still builds newer Swift code with an older version set

I’m building source code using an Xcode project that has its “Swift Language Version” set to “Swift 4.” Even with this set, the project builds Swift 5.1 source code like, for example, implicit returns and Swift 5 source code using the new `isMultiple(of:)` method.



The Swift 5 and 5.1 code still works even with “Swift Language Version” set to “Swift 4” or “Swift 4.2”



It’s only when running `#elseif swift(>=4.1)` statements that there appears to be a difference (code from https://stackoverflow.com/a/46080904/414415). Those results output their expected results.



However, I’m left wondering, how does the my Swift 5 source code compile successfully when the build setting clearly states Swift 4? And if the setting does not change which version of Swift I can use, what does it actually do?

Powered by WPeMatico

You may also like...

Comments are closed.