LoginSignup
4
6

More than 3 years have passed since last update.

iOS13&Xcode11ではSKStoreProductViewControllerを継承したクラスが使えなくなりました

Posted at

環境

  • iPhone 11 Pro Max
  • iOS13.0
  • Xcode11.1 GM

原因

  • タイトルそのまま

エラーログ

error.log
*** Terminating app due to uncaught exception 'SKUnsupportedClassException', reason: 'SKStoreProductViewController may not be subclassed.'

対応

  • 継承したクラスの削除
  • 呼び出し処理の追記
SampleViewController.swift
internal final class SampleViewController {
    internal func openStoreProduct() {
        let storeProductViewController = SKStoreProductViewController()
        storeProductViewController.delegate = self

        // StoreのIDを追記
        let parameters = [SKStoreProductParameterITunesItemIdentifier: 000000];
        storeProductViewController.loadProduct(withParameters: parameters) { [weak self] status, error -> Void in
            guard let self = self else { return }
            if status {
                self.present(storeProductViewController, animated: true) { [weak self] in
                    // 閉じた時の処理
                }
            } else {
                if let error = error {
                    print("Error: \(error.localizedDescription)")
                }
            }
        }
    }
}

extension SampleViewController: SKStoreProductViewControllerDelegate {
    internal func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
        viewController.dismiss(animated: true, completion: nil)
    }
}
4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6