Search code examples
swiftmacosuikitmac-catalystuiscenedelegate

macOS Catalyst `requestSceneSessionActivation` requires multiwindow adoption


When trying to open a new window in a macOS Catalyst application, I'm using this enum to describe an instance of NSUserActivity:

enum Activity: String {
  case list
  case settings

  var type: String {
    "com.example.app.\(rawValue)"
  }

  var userActivity: NSUserActivity {
    NSUserActivity(activityType: type)
  }
}

Then to open a new window, I use this code in a button tap handler, as described in this raywenderlich.com tutorial:

UIApplication
  .shared
  .requestSceneSessionActivation(
    nil,
    userActivity: Activity.settings.userActivity,
    options: nil,
    errorHandler: nil
  )

However, this doesn't work and I always get this error message in the debugger console:

[Scene] Calling -[UIApplication requestSceneSessionActivation:] requires multiwindow adoption.

What does this error message mean and what are possibly missing steps here to make support for multiple windows work in a Catalyst app?


Solution

  • What actually worked is setting UIApplicationSupportsMultipleScenes key within UIApplicationSceneManifest dictionary to YES in your Info.plist:

        <key>UIApplicationSceneManifest</key>
        <dict>
            <key>UIApplicationSupportsMultipleScenes</key>
            <true/>
        </dict>
    

    Or if you prefer Xcode GUI, check out this screenshot:

    Info.plist in Xcode with the "Enable Multiple Windows" setting

    Unfortunately, this setting doesn't seem to be documented in the raywenderlich.com tutorial or in any of Apple's guides on Catalyst. It only seems to be documented on this Developer reference page.