What’s the present best-practice for supporting an exterior show in a SwiftUI iOS app in 2024? Not easy mirroring, however really displaying completely different content material than the machine.
The one docs I discovered require abandoning the SwiftUI App construction and “switching again to a full UIKit App Delegate”.
Is that this nonetheless the one choice?
Are there any full examples on learn how to accomplish this?
Even the examples I discovered I can’t get working b/c the registered delegate by no means will get known as.
Data.plist
is configured as:
UIApplicationSceneManifest
UIApplicationSupportsMultipleScenes
UISceneConfigurations
UIWindowSceneSessionRoleExternalDisplayNonInteractive
UISceneConfigurationName
Exterior Show
UISceneDelegateClassName
$(PRODUCT_MODULE_NAME).ExternalDisplaySceneDelegate
And right here is the delegate class:
remaining class ExternalDisplaySceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
choices connectionOptions: UIScene.ConnectionOptions) {
print("exterior scene") // ⬅︎----- I can by no means get this to print
guard let scene = scene as? UIWindowScene else {
return
}
let content material = ExternalDisplayView()
window = UIWindow(windowScene: scene)
window?.rootViewController = UIHostingController(rootView: content material)
window?.isHidden = false
}
}
Am I doing one thing flawed?
Is there a greater means?
(Observe: I am solely fascinated with iOS 17 and/or iOS 18)
Thanks upfront.