I just upgraded to Xcode 9.0 Beta and now my app crashes on launch.
2017-06-09 14:35:18.817213-0700 recharge-consumer-ios[13524:1720597] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[recharge_consumer_ios.SignedOutContainerViewController<0x105c691b8> init]: cannot init a class object.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010caf4f6b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ba3e121 objc_exception_throw + 48
2 CoreFoundation 0x000000010cb7f6ff +[NSObject(NSObject) init] + 127
3 recharge-consumer-ios 0x0000000105322223 _T021recharge_consumer_ios22RechargeViewControllerCACycfCTD + 19
The call that is failing is (simplified):
func setAndRefreshChildViewControllersWithTypes(_ types: [MyViewControllerProtocol.Type]) {
for type in types {
let controller = type.init() as! UIViewController // This is what crashes
}
...
}
Where MyViewControllerProtocol
is:
protocol MyViewControllerProtocol {
// some other fields here too
init()
}
And the instance that is failing looks like:
class SignedOutContainerViewController: MyViewController {
required init() {
super.init(nibName: "SignedOutContainerViewController")
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
where MyViewController
is:
class MyViewController: UIViewController, MyViewControllerProtocol {
required init() {
fatalError("init has not been implemented")
}
init(nibName nibNameOrNil: String?) {
super.init(nibName: nibNameOrNil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Any idea what's going wrong, or pointers on where else to look? Xcode 9.0 Beta (9M136h), swift 3.