1

I am trying to load a view controller from the main storyboard programmatically from the app delegate. I am using Xcode 11.1 and Swift 5. Additionally, I have NOT designated main storyboard as the 'main interface' in deployment info and there is no initial view controller defined in the storyboard.

However, when I am running the app, instead of seeing vc1 controller, the app crash and I see the following error message:

"2019-10-11 16:07:48.958933-0400 MyApp[891:16923] [WindowScene] Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?"

I did some google search and it seems like the code recommendation I am getting is similar to what I have. Can someone please help me identify what am I doing wrong and how to solve it?

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 storyboard = UIStoryboard(name: "Main", bundle: nil)

        let initialViewController = storyboard.instantiateViewController(withIdentifier: "vc1")

        self.window?.rootViewController = initialViewController
        self.window?.makeKeyAndVisible()

        return true

Thanks in advance for your help.

  • 1
    Possible duplicate of [Xcode 11 & iOS13, using UIKIT can't change background colour of UIViewController](https://stackoverflow.com/questions/58251425/xcode-11-ios13-using-uikit-cant-change-background-colour-of-uiviewcontroller) – valosip Oct 13 '19 at 22:23

0 Answers0