The app delegate must implement the window property if it wants to use a main storyboard file swift

后端 未结 10 1691
臣服心动
臣服心动 2020-12-07 17:27

I have just developed an app, but when running in the simulator the debugger console says:

The app delegate must implement the window property if it w

10条回答
  •  有刺的猬
    2020-12-07 18:22

    I have received this error, when I created new project in XCode 11. I have not used SwiftUI. Here are the steps, I have considered to fix this.

    1. Deleted Application Scene Manifest entry from Info.plist
    2. Deleted SceneDelegate.swift file
    3. Deleted all scene related methods in AppDelegate.swift class
    4. added var window: UIWindow? property in AppDelegate.swift class

    After these steps, I am able to run the app on version prior to iOS 13.

    [EDIT]
    Finally, your AppDelegate.swift file should look something like the following.

    import UIKit
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        var window: UIWindow?
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            // Override point for customization after application launch.
            return true
        }
    
    }
    

提交回复
热议问题