You can return any types’ name by using string interpolation:
class MyClass<T> {
func genericName() -> String {
return "\(T.self)"
}
}
You can try it in a playground and it works as expected:
var someClass = MyClass<String>()
someClass.genericName() // Returns "Swift.String"