Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 wants to use a main storyboard file.

I have an app delegate file. What does the message mean, and how can I get my app working?

like image 779
Ethan Marcus Avatar asked Apr 04 '15 01:04

Ethan Marcus


2 Answers

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

var window: UIWindow? 
like image 199
muneeb Avatar answered Oct 03 '22 02:10

muneeb


If you run your project on earlier than iOS 13.0, in that case you will face the problem. Because of iOS 13 and later, app launch differently than earlier versions.

  • In iOS 13 and later, use UISceneDelegate objects to respond to life-cycle events in a scene-based app

  • In iOS 12 and earlier, use the UIApplicationDelegate object to respond to life-cycle events.

When you launch the app in iOS 12 and earlier then UIApplicationMain class expect a window property in your AppDelegate class as like SceneDelegate has. So your problem will be solved if you add the following line in your AppDelegate class.

var window: UIWindow? 

For Objective-C

@property (strong, nonatomic) UIWindow *window; 

You can find more here App's Life Cycle.

like image 23
Muzahid Avatar answered Oct 03 '22 01:10

Muzahid