The Swift stdlib is swizzling +[NSBundle bundleForClass:] in order to handle Swift classes properly. Unfortunately it crashes if the passed class is nil. The API itself is documented as taking a nonnull parameter, but the actual observed behavior at runtime of [NSBundle bundleForClass:nil] without Swift is to return the same thing as [NSBundle mainBundle].
Unfortunately, this crash is a showstopper for us for using Xcode 10.1 because a closed-source dependency of ours is apparently calling [NSBundle bundleForClass:nil].
The text was updated successfully, but these errors were encountered:
In general, any swizzles performed by Swift should be written as defensively as possible, including not making any assumptions that the nullability annotations can be relied upon. The existing framework methods frequently actually handle null objects passed to nonnull parameters because these APIs were written long before nullability annotations were a thing.