Getting the name of a typealias as a string

In a project I'm working on, I need to get a string of the typealias' name. When trying to do that, I am instead given the name of the type that is being aliased.

typealias FooString = String

String(describing: String.self)    // returns "String"
String(describing: FooString.self)    // returns "String", but I need "FooString"

Is there any way to get the name of FooString as a string at runtime?

Unfortunately no; it's very deliberate that a typealias does not have any run-time representation. You may want to write a struct that wraps String instead.

OK thanks for the info. My use case was basically just that I needed to create a unique identifier based on the type, but that identifier needed to be consistent across executions of the app.

I'll try to come up with an alternative approach.

You might want to look into ObjectIdentifier type

That's close to what I wanted, but from what I can tell it's value changes between executions of the app.

I'm looking into what Jordan suggested above and am working on something that is pretty much a copy of NSNotification.Name. It requires users to do more work, but I suppose it's more reliable than using a type name as a persistent identifier.

Edit: Actually an ObjectIdentifier of FooString vs String is still equal, unfortunately.