Using Xcode 12.5 I have identified an issue with this instruction "(Self.self)" when it runs on a build created setting SWIFT_OPTIMIZATION_LEVEL to -O (Optimize for speed).
The instruction above is executed in a superclass (subclass of UIView) when it to load a NIB:
Instead of getting the right subclass name, it simply returns "Self" and this generate the following error:
This never happens before with previous versions of Xcode, and it still does not happen when the build is generate without using optimization -Onone.
To fix it I have changed "(Self.self)" with "(type(of: self))". This way it works, but I think that it should be investigate why the original version causes that kind of issue when Swift is optimized.
Forcing optimization in Debug, I was able to reproduce the issue. I have also tried to insert a breakpoint before the crash, trying to execute the instruction in Console with po command, but it works as expected, printing the right class name.