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

后端 未结 10 1693
臣服心动
臣服心动 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:24

    Make sure you have the following property declaration in your AppDelegate class:

    var window: UIWindow?
    
    0 讨论(0)
  • 2020-12-07 18:25

    Add the following window declaration in Appdelegate file

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
        
        var window:UIWindow?
        ...
    

    Implementation of this property is required if your app’s Info.plist file contains the UIMainStoryboardFile key. The default value of this synthesized property is nil, which causes the app to create a generic UIWindow object and assign it to the property. If you want to provide a custom window for your app, you must implement the getter method of this property and use it to create and return your custom window.

    0 讨论(0)
  • 2020-12-07 18:28

    Setting in Info.plist Application Scene Manifest > Enable Mutliple Windows > false. This solved the problem for me.

    0 讨论(0)
  • 2020-12-07 18:30

    Swift 5 & Xcode 11

    Make sure that SceneDelegate contains UIWindow property

    class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
        var window: UIWindow?
    
        //...
    }
    
    0 讨论(0)
提交回复
热议问题