Unable to get external display working

Trying to get my iPad app to display a different view on connected external display. Info.plist is setup as follows:

<dict>
	<key>UIApplicationSceneManifest</key>
	<dict>
		<key>UIApplicationSupportsMultipleScenes</key>
		<true/>
		<key>UISceneConfigurations</key>
		<dict>
			<key>UIWindowSceneSessionRoleExternalDisplayNonInteractive</key>
			<array>
				<dict>
					<key>UISceneConfigurationName</key>
					<string>External Display</string>
					<key>UISceneDelegateClassName</key>
					<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
				</dict>
			</array>
		</dict>
	</dict>
</dict>

I have my SceneDelegate setup as the follows:

import SwiftUI

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?
 
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = scene as? UIWindowScene else { return }
 
        if session.role == .windowExternalDisplayNonInteractive {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = UIHostingController(rootView: ExternalDisplayView())
            self.window = window
            window.makeKeyAndVisible()
        }
    }
}

I've tested running on a physical iPad with usb-c to hdmi connected and it only mirror's the screen. Same when connecting to AirPlay. Also tested running a simulator with external display enabled. Is there something I'm missing?

Answered by blades in 853755022

I got this working for some reason the issue was a multiplatform target. I switched to a iOS only target and it's working fine.

does your iPad support anything other than mirroring?

See https://support.apple.com/guide/ipad/connect-to-a-display-with-a-cable-ipadf1276cde/18.0/ipados/18.0

Also, you need a touchpad or mouse, because otherwise you can't manipulate windows on the external screen. And you might need an external keyboard too.

My physical iPad only supports mirroring. However the iPad simulator on my mac should be working. When external display is connected to simulator it just displays black.

Accepted Answer

I got this working for some reason the issue was a multiplatform target. I switched to a iOS only target and it's working fine.

Unable to get external display working
 
 
Q