Determining the Swift runtime version

I'm curious how I can determine what the active Swift runtime version is from a crash report.

I assume this will depend on the OS version, when it bundles the Swift runtime.

On iOS, my crash report mentions:

0x188189000 -         0x18872afff libswiftCore.dylib arm64e  <e9b1dc6b7fef3bbbb083f4e8faaa53df> /usr/lib/swift/libswiftCore.dylib

And:

OS Version:          iPhone OS 18.2.1 (22C161)

Though it isn't clear how to map this back to a Swift runtime version. A quick web search does not immediately identify any publications clarifying what Swift runtime is bundled with iOS 18.2.1, nor does a search for the libswiftCore.dylib hash yield any documented mappings.
Is this information advertised somewhere, or is there another method by which to resolve this information?

More specifically, I'm looking to evaluate:

Thread 0 Crashed:
0   libswiftCore.dylib                  0x000000018856bcc0 swift::TargetMetadata<swift::InProcess>::isCanonicalStaticallySpecializedGenericMetadata() const + 280          (Metadata.cpp:624)

This was compiled under:

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

But that does not appear to map correctly: swift/stdlib/public/runtime/Metadata.cpp at swift-6.0.3-RELEASE · swiftlang/swift · GitHub

(The underlying crash was reported as `-O` breaks KeyPath resolution · Issue #78948 · swiftlang/swift · GitHub)

I recently saw that the stdlib has a constant _SwiftStdlibVersion.current since Swift 5.7 that tells you what major and minor version you're running, though unfortunately not the patch version. :slightly_frowning_face: I saw that the new Testing library uses it to report what it's running the tests against.

I have no idea what iOS allows to get that data back to you though, whether sending back custom data with the crash report log or if you'll have to start telling your app at startup to report the iOS and stdlib versions back to your server, so you can compile a table of corresponding versions to use later.

It's an underscored symbol, which means (at best) Use At Your Own Risk. Don't follow our lead here please—while we use it for diagnostic purposes, we're bad people and we should feel bad about it.

4 Likes