3 Replies
      Latest reply on Oct 14, 2019 1:06 PM by Claude31
      flarosa Level 1 Level 1 (0 points)

        I've been using this code to create simple apps for years, but it is suddenly not working anymore with iOS 13 and Xcode 11. When I run the app I just get a blank screen. What am I doing wrong?

         

          var window: UIWindow?
        
          func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
          {
          window = UIWindow(frame: UIScreen.main.bounds)
          window?.rootViewController = UINavigationController(rootViewController: HomeViewController())
          window?.makeKeyAndVisible()
          return true
          }
        
        
        • Re: makeKeyAndVisible doesn't work?
          Claude31 Level 8 Level 8 (7,245 points)

          Have you checked if you have a sceneDelegate file ?

          If so, you need to add an entry in your infos.plist:

           

          <?xml version="1.0" encoding="UTF-8"?>

          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

          <plist version="1.0">

          <dict>

              <key>UIApplicationSupportsMultipleScenes</key>

              <false/>

              <key>UISceneConfigurations</key>

              <dict>

                  <key>UIWindowSceneSessionRoleApplication</key>

                  <array>

                      <dict>

                          <key>UISceneConfigurationName</key>

                          <string>Default Configuration</string>

                          <key>UISceneDelegateClassName</key>

                          <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>

                          <key>UISceneStoryboardFile</key>

                          <string>Main</string>

                      </dict>

                  </array>

              </dict>

          </dict>

          </plist>

           

           

          Why do you need to create the window ?

           

          In my apps, view is created in IB and I do not need to call window nor set it key and visible.

            • Re: makeKeyAndVisible doesn't work?
              flarosa Level 1 Level 1 (0 points)

              Thanks, I did have a scene delegate, and removing it fixed the issue.

               

              I guess a scene delegate is something new that Xcode gives you by default. I had never even heard of a Scene before.

                • Re: makeKeyAndVisible doesn't work?
                  Claude31 Level 8 Level 8 (7,245 points)

                  Thanks for the feedback, glad for you it works. And don't forget to close the thread.

                   

                  To answer your last question: Scenes are effectively new.

                  Note that scenes will become compulsory for any iPad app as soon as april 2020.

                  There is a good WWDC 2019 session (258 I think) about it.

                   

                  In fact, adopting scene management, even on an existing project is very easy:

                  - create the sceneDelegate.swift

                  - you can keep the appdelegate functions as is ; they will be ignored on IOS 13, except appDidFinishLaunching

                  - In the sceneDelegate, declare all func with @available(iOS 13.0, *)

                  - transfer the content of appDelegate func (such as didBecomeActive) to their equivalent in SceneDelegate

                  - add the infos.plist section (you can copy and paste the whole section from a void project you create)

                  - don't forget to set the VC presentation to fullScreen instead of Automatic (otherwise, strange small size views on iPad).

                   

                  And that's it.