SwiftでiOSアプリを作っています。  
アプリ起動時に、SwiftyStoreKitを使用して、  
すでにアプリ購入済みならAlreadyPurchacedStoryboardを表示し  
未購入ならPurchaceStoryboardを表示したいと思っています。

以下がAppDelegate.swiftのコードですが、ビルドするとエラーになります。  
(ビルド前にはエラーは出ません。)

**AppDelegate.swift**

```

    import UIKit
    import SwiftyStoreKit
    
    @UIApplicationMain
    
    class AppDelegate: UIResponder, UIApplicationDelegate {
        var window: UIWindow?
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
            self.window = UIWindow(frame: UIScreen.main.bounds)
            let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "xxxxxxx")
            SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
                switch result {
                case .success(let receipt):
    
                    let productId = "com.musevisions.SwiftyStoreKit.Subscription"
    
                    // Verify the purchase of a Subscription
                    let purchaseResult = SwiftyStoreKit.verifySubscription(
                        ofType: .autoRenewable, // or .nonRenewing (see below)
                        productId: productId,
                        inReceipt: receipt)
    
                    switch purchaseResult {
                    case .purchased://既に購入済みだった場合
                        //　Storyboardを指定
                        let storyboard = UIStoryboard(name: "AlreadyPurchacedStoryboard.", bundle: nil)
                        let initialViewController = storyboard.instantiateInitialViewController()
                        self.window?.rootViewController = initialViewController
                    case .expired,.notPurchased://未購入だった場合
                        //　Storyboardを指定
                        let storyboard = UIStoryboard(name: "PurchaceStoryboard", bundle: nil)
                        let initialViewController = storyboard.instantiateInitialViewController()
                        self.window?.rootViewController = initialViewController
                    }
                case .error(let error):
                    print("Receipt verification failed: \(error)")
                }
            }
    
            self.window?.makeKeyAndVisible()
            return true
        }
    }
    
```

エラー内容は以下です。  
AppDelegateのクラス定義の行でエラーが出ています。

```

    Thread 1: Exception: "Application windows are expected to have a root view controller at the end of application launch"
    
```

コンソールには以下のようなエラー内容が表示されています。

```

    2020-06-20 11:45:54.736792+0900 testApp[468:25036] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3920.31.101/UIApplication.m:4304
    
    2020-06-20 11:45:54.736995+0900 testApp[468:25036] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
    
    *** First throw call stack:
    
    (0x186b94300 0x1868a8c1c 0x186a911f8 0x186ed5998 0x18acdb4c0 0x18a44b03c 0x18a916d68 0x18a44bb70 0x18a44b59c 0x18a44b98c 0x18a44b214 0x18a44f930 0x18a835604 0x18a930a0c 0x18a44f66c 0x18a9308f4 0x18a44f4c4 0x18a2b5ba4 0x18a2b46a4 0x18a2b58d4 0x18acd93fc 0x18a85be08 0x18bdf6ffc 0x18be1d5a0 0x18be01ebc 0x18be1d234 0x10190718c 0x10190a964 0x18be436c4 0x18be43370 0x18be438dc 0x186b0faf4 0x186b0fa48 0x186b0f198 0x186b09f38 0x186b098f4 0x190f20604 0x18acdd358 0x100ec17f0 0x1869852dc)
    
    libc++abi.dylib: terminating with uncaught exception of type NSException
    
```

どうしたらエラーなく起動できますでしょうか？
CC BY-SA 4.0
2020-06-20T03:19:48.003
67822
2020-06-20T03:19:48.003
36446
question
swift ios
SwiftyStoreKitでのエラー：Thread 1: Exception: "Application windows are expected to have a root view controller at the end of application launch"