1

I'm running on Catalina Beta 2 and using Xcode 11 Beta 2. I've created and built the default template SwiftUI project and it loads fine. I then opened a small project I created in Xcode 10 using storyboards and copy-n-pasted the setup from Apple's template project.

Everything looks the same across the app, Info.plist, settings, app delegate, scene delegate etc and I've gone over it many times looking to see what's wrong.

Here is my current app delegate:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        return true
    }

    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        let config = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
        return config // <<<<< Breakpoint !!!!
    }

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    }
}

In Apples template project this works, but in mine it doesn't.

Stopping at the breakpoint in mine I can see that the connectingSceneSession and loaded config have ignored the scene details in the Info.plist. Instead a default config is created with a nil scene delegate and the role of an external display.

The really weird thing is that if I execute:

po UISceneConfiguration(name: "Default Configuration", sessionRole: .applicationWindow)

In the debug console, then it loads up the scene from the Info.plist exactly as I would expect.

The core of the problem seems to be that the app is failing see the definition of the scene in the Info.plist and returning a new external display scene instead. Even after I tried replacing the app's Info.plist with the one from Apple's example app.

Anyone got any idea what might be going on?

drekka
  • 20,957
  • 14
  • 79
  • 135
  • 1
    Check my answer here: https://stackoverflow.com/a/56515686/2890168. It might help. – Matteo Pacini Jun 18 '19 at 17:05
  • Thanks @MatteoPacini your answer is one of the references I've been checking against to try and solve this. So far - I've either missed something obvious or there's something else at play here. So setting that's effecting the way the scene is loaded. – drekka Jun 19 '19 at 03:40

1 Answers1

1

Found it.

It wasn't a setting or a piece of code or the derived data. It was that the pre-SwiftUI app had been on the simulator. Once I reset the simulator everything started working.

drekka
  • 20,957
  • 14
  • 79
  • 135