I root caused my occurrence of this error to usage of 'Self' in a class func for a XIB UIView. The error happened for me in XCode 11.5 and only the release build of the project. So, looks like the issue is in -O compilation. (It looks like the academic project named Swift has rediscovered the useful concept of Self)
THE EXAMPLE BELOW CAUSES segfault 11, FIXED BY REPLACING THE THREE "Self" WITH CLASS NAME "StyleHSView":
class StyleHSView: UIStackView, UITextFieldDelegate {
@IBOutlet weak var styleNameTF: UITextField!
@IBOutlet weak var urlTF: UITextField!
// THIS FUNC CAUSES segfault 11, fix by changing Self to class name StyleHSView.
class func Instantiate() -> Self {
let nib = UINib.init(nibName: "StyleHSView", bundle: nil)
if let view = nib.instantiate(withOwner: nil, options: nil).first(where: { return $0 is Self }) as? Self
{
return view
} else {
fatalError("No StyleHSView")
}
}
}