1

I am not using main.storyboard at all and making everything through code, but I get this error with this code in my app delegate.

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let rootView = HomeCollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

        if let window = self.window {
            window.rootViewController = rootView
        }

        return true
    }
joethemow
  • 1,641
  • 4
  • 24
  • 39

3 Answers3

2

If you are not planning on using the storyboard you need to still make some configurations in the project file to let the Xcode know. Under target -> Deployment info you can see a setting for Main Interface, set it as blank then it will not look for the entry point in the storyboards.

enter image description here

Also, when you are doing everything in code, UIWindow instance needs to be instantiated and made visible which allows you to start presenting view controllers.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let viewController = TestViewController()

    self.window = UIWindow(frame: UIScreen.main.bounds)
    self.window?.rootViewController = viewController
    self.window?.makeKeyAndVisible()

    return true
}
GoodSp33d
  • 6,252
  • 4
  • 35
  • 67
1

You can just delete the key from your .plist file Main storyboard file baseand run it again.

Also if you are getting the black screen you have to setup window by self.window?.makeKeyAndVisible() like above answer.

Salman Ghumsani
  • 3,647
  • 2
  • 21
  • 34
0

Above my comment, adding an answer. If you are using a storyboard which is dummy for you at this point, you should add a View Controller to your UIStoryboard. If you want to remove your UIStoryboard, you can still continue without it. In stackoverflow its been answered here.

ridvankucuk
  • 2,407
  • 1
  • 23
  • 41