Home > Software design >  SKStoreProductViewController crashes for unrecognized selector named sceneDisconnected: in iOS 15.6
SKStoreProductViewController crashes for unrecognized selector named sceneDisconnected: in iOS 15.6

Time:07-09

In iOS 15.6 beta5 and iOS 16.0 beta:

When an UISceneDidDisconnectNotification was posted, any active SKStoreProductViewController instance would crash for the unrecognized selector named sceneDisconnected.

-[SKStoreProductViewController sceneDisconnected:]: unrecognized selector sent to instance 0x115161a00

This crash only happened in the latest iOS15.6 and iOS16 beta version. Yet I can't find the selector name in any official documents……

Any solutions? Or Is there anything I haven't done right?

CodePudding user response:

Not a solution, but a clear indication that this is Apple's bug to fix. Starting with a clean sample project, all you need to do is present a SKStoreProductViewController and then force quit your application:

import StoreKit
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let storeKitViewController = SKStoreProductViewController()
        storeKitViewController.loadProduct(withParameters: [
            SKStoreProductParameterProductIdentifier: "364709193"
        ])
        present(storeKitViewController, animated: true)

        // Force quit after presentation to trigger crash
        // -[SKStoreProductViewController sceneDisconnected:]: unrecognized selector sent to instance
    }

}

I've filed this with Apple via Feedback Assistant.

CodePudding user response:

This is actually an inaccurate reporting because it doesn't actually cause the crash.

I reproduced the reported scene: click on the app-download advertisement in your app, pop up the in-app App Store download page, and then back to the background, the crash message is generated in this time -- but no crash actually occurred, and nothing changed when I returned to the foreground. Everything works fine. The next time the app starts, the crash information will be reported.

So no need to do anything now, just wait for Apple to fix it.

  • Related