How to Check Swift Version (The Easy Way)

To check the Swift version of your current Xcode project:

  1. Click on your project’s .xcodeproj file.
  2. Choose Build Settings.
  3. Search for “Swift language version” using the search bar.
  4. See the Swift version used by this project.

If you click the Swift version you are going to see other Swift versions in a dropdown. These are all the other supported Swift versions available for this project.

How to Check the Swift Version Programmatically

To programmatically find out the Swift version of your project, check if the current version matches with one of the versions there has ever been.

#if swift(>=5.5)
print("Swift 5.5")

#elseif swift(>=5.4)
print("Swift 5.4")

#elseif swift(>=5.3)
print("Swift 5.3")

#elseif swift(>=5.2)
print("Swift 5.2")

#elseif swift(>=5.1)
print("Swift 5.1")

#elseif swift(>=5.0)
print("Swift 5.0")

#elseif swift(>=4.2)
print("Swift 4.2")

#elseif swift(>=4.1)
print("Swift 4.1")

#elseif swift(>=4.0)
print("Swift 4.0")

#elseif swift(>=3.2)
print("Swift 3.2")

#elseif swift(>=3.0)
print("Swift 3.0")

#elseif swift(>=2.2)
print("Swift 2.2")

#elseif swift(>=2.1)
print("Swift 2.1")

#elseif swift(>=2.0)
print("Swift 2.0")

#elseif swift(>=1.2)
print("Swift 1.2")

#elseif swift(>=1.1)
print("Swift 1.1")

#elseif swift(>=1.0)
print("Swift 1.0")

#endif

As a result, this prints the Swift version used by the project.

Check the Swift Version on Your System

You can have Swift installed on your computer without having Xcode. In other words, it is possible to have a different Swift version on your system than the one used by Xcode.

In case you are interested in knowing the Swift installed on your system, you can run the following command in a Terminal window:

swift -version

Example output:

Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0

Usually, this is also the version of Swift that your Xcode application uses. But you could change it.

Check the Swift Version of an Xcode App with the Terminal

You can also use Terminal to check the Swift version of the Xcode app.

To check any Xcode app’s Swift version, run the following command in the terminal:

/Applications/<YOUR_XCODE_APPLICATION>/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version

By replacing <YOUR_XCODE_APPLICATION> with the name of the Xcode app in your Applications folder.

For example, if your Xcode application is called Xcode_12.5.app, run:

/Applications/Xcode_12.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version

Conclusion

Today you learned how to find out the Swift version on Xcode and on your system.

To recap, you can:

  1. Manually check the project-specific Swift version on Xcode’s build settings.
  2. Programmatically check the project-specific Swift version by checking if the version matches any existing Swift version.
  3. Check the version of Swift installed on your system by running swift -version in Terminal
  4. Use Terminal to check the Xcode-specific Swift version by running the following command:
/Applications/<YOUR_XCODE_APPLICATION>/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version

Thanks for reading.

Happy coding!

Scroll to Top