How can I determine the Swift compiler version used to create a Framework?

So I have a compiled library (Mac os) and I want to know what compiler version was used exactly. In my example I tried the following:

otool -L TestFramework 
TestFramework:
	@rpath/TestFramework.framework/Versions/A/TestFramework (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1675.129.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1103.8.25)

It looks like 1103.8.25 could be useful, but when I look the version up (on Wikipedia) it doesn't help, as the versions there look like this:

5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1),
5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8),
5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
etc..

It looks like that my 1103.8.25 might hint to one of these:

5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29),
5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51),
5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53),
5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53),
5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)

, because of the 1103 but which one is it?

(I can ask Xcode but I want to know how Xcode knows..)

1 Like

So I have a compiled library (Mac os) and I want to know what compiler
version was used exactly.

Was your library compiled in ABI stable mode? That is, with Build Libraries for Distribution (BUILD_LIBRARY_FOR_DISTRIBUTION) set? If so, the .swiftinterface file contains the info you need:

// swift-compiler-version: Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Thank you eskimo. Unfortunately it really matters for me to get that information when it's not built with ABI stable mode, otherwise things are simpler.

How does Xcode do it? Surely they must be looking at the required library versions.. is there a list somewhere of them? So we can derive a swift language version from, for example, libswiftCore.dylib's version?

1 Like