Adopt the UIScene lifecycle on tvOS - #719
Open
bartleman wants to merge 1 commit into
Open
Conversation
An app built against the tvOS 27 SDK that still uses the legacy UIApplicationMain + storyboard lifecycle fails to launch: the system logs "UIScene life cycle is required for apps built with this SDK", scene creation fails, and the app exits before main. (Apps built against the tvOS 26.5 SDK are exempt and still run on tvOS 27.) Add a minimal UIApplicationSceneManifest to the tvOS Info.plist and a small UIWindowSceneDelegate that builds the window from the Main storyboard. The scene delegate is declared in AppDelegate.m under TARGET_OS_TV to avoid adding a new source file to the project. Also make the HDR/refresh-rate display code scene-safe: under the scene lifecycle the app delegate's -window is nil, so read the window from the view controller (with a legacy fallback). The scene manifest is backward compatible - on tvOS versions predating scenes the app falls back to the legacy lifecycle. Only the tvOS target is touched; the iOS target is unchanged (it will need the same migration when built against a future iOS SDK that enforces scenes). Tested on Apple TV 4K (tvOS 27.0) built with Xcode 27: the app launches, the UI appears, and streaming works; the tvOS 26.5-SDK build is unaffected. Claude-Session: https://claude.ai/code/session_01QiVtyqxowFKZc8gKnNjevy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An app built against the tvOS 27 SDK that still uses the legacy
UIApplicationMain+ storyboard lifecycle fails to launch. The system refuses to create its scene and the app exits beforemain, with this in the device log:Apps built against the tvOS 26.5 SDK are exempt and still run on tvOS 27, so this only bites once you build the tvOS target with Xcode 27 / the tvOS 27 SDK.
Fix
UIApplicationSceneManifesttoMoonlight TV/Info.plist.UIWindowSceneDelegatethat builds the window from theMainstoryboard. To avoid adding a new source file to the project, it's declared inAppDelegate.munder#if TARGET_OS_TV.-windowisnil, soupdatePreferredDisplayMode:now reads the window from the view controller (self.view.window) with a fallback to the app delegate's window for the legacy lifecycle.Notes
TVOS_DEPLOYMENT_TARGET.Testing
Built with Xcode 27 beta against the tvOS 27 SDK and run on an Apple TV 4K (3rd gen), tvOS 27.0 (24J5346a): the app launches, the UI appears, host discovery/pairing work, and streaming works. Also verified the tvOS 26.5-SDK build (Xcode 26.6) still launches and runs normally with this change (no regression).