環境
- 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)
}
}