Add this code in application(_:didFinishLaunchingWithOptions:)
(at least before the app is terminated). It adds the methods at runtime if they don’t exist.
if #available(iOS 15.7, *) {
if #unavailable(iOS 16.0) {
class_addMethod(
SKStoreProductViewController.self,
Selector(("appWillTerminate")),
unsafeBitCast({ _, _ in } as @convention(c) (SKStoreProductViewController, Selector) -> Void, to: IMP.self),
"v@:"
)
class_addMethod(
SKStoreProductViewController.self,
Selector(("sceneDisconnected:")),
unsafeBitCast({ _, _, _ in } as @convention(c) (SKStoreProductViewController, Selector, NSNotification) -> Void, to: IMP.self),
"v@:@"
)
}
}
It seems they removed appWillTerminate
and sceneDisconnected(_:)
methods in iOS 15.7, but forgot to remove the code that adds UIApplication.willTerminateNotification
and UIScene.didDisconnectNotification
observers to the NotificationCenter.
Edit: They seem to have re-added appWillTerminate
and sceneDisconnected(_:)
methods in iOS 15.7.1. So I’ve updated the code to add the methods only in iOS 15.7.
Edit: They removed the methods AGAIN in iOS 15.7.2 and the crash recurred. I’ve reverted the code.