Adopt scene lifecycle in UnitTestsHostApp for iOS 27 support#6980
Conversation
There was a problem hiding this comment.
Somehow, it seems like adopting the scene-based lifecycle removed some padding between the navigation bar and the content. I don't think this is a regression, just a change in how the app is presenting views.
There was a problem hiding this comment.
Here's Codex's take on it:
The likely reason is that the test host now has a real UIWindowScene and key UIWindow.
Before scene adoption, UnitTestsHostApp was basically a launched app with no UIKit scene/window. SnapshotTesting’s UIHostingController was rendered in a more isolated UIKit environment. After the migration, SwiftUI can inherit real window/scene traits and UIKit navigation bar behavior from an active scene.
DebugViewSwiftUITests snapshots this:
NavigationView {
DebugSummaryView(model: model)
}
.frame(width: width, height: height)
.snapshot(size: CGSize(width: width, height: height))On iOS 26, NavigationView/UINavigationController layout is sensitive to whether it is attached to a real scene/window. With a scene-backed host, SwiftUI likely resolves the navigation bar/safe-area layout differently, so the content starts closer to the nav bar. That manifests as “padding removed” at the top.
One extra clue from the run: UIKit logged:
Info.plist contained no UIScene configuration dictionary (looking for configuration named "Default Configuration")
That means our minimal plist manifest plus configuration.delegateClass = SceneDelegate.self works, but UIKit still looked for a named scene config in the plist first. It probably falls back correctly, but this reinforces that we’re now in full UIKit scene lifecycle behavior, not the old no-scene host environment.
So: not a DebugSummaryView change. It’s almost certainly a snapshot environment change caused by giving the host app a real scene/window, which changes NavigationView’s safe-area/nav-bar layout on iOS 26.
This reverts commit 6df663c.
…hub.com/RevenueCat/purchases-ios into adopt-scene-lifecycle-in-unit-tests-app
ajpallares
left a comment
There was a problem hiding this comment.
Thanks for fixing this! One small question though
| @@ -31,6 +31,34 @@ struct TestApp: App { | |||
| // Scene isn't available until iOS 14.0, so this is for backwards compatibility. | |||
There was a problem hiding this comment.
Question, but not blocking (since we're not really running iOS 13 tests on CI).
Does this mean that these tests won't be able to run on iOS 13 now?
There was a problem hiding this comment.
I'm honestly not sure. I don't have a iOS 13 simulator to test with, and we aren't running them in CI today. Either way, the new min OS version for Xcode 27 is iOS 15, so we'll be dropping it soon anyways. Any objection to merging as-is, or would you prefer we take the time to ensure that it still runs on iOS 13 somehow?
There was a problem hiding this comment.
Oh true! I think we can merge as is, indeed. We can change this if we need to in the future for iOS 13. So I think it's better to be prepared for iOS Xcode 27 so that we can enable it in CI as soon as it's available in CircleCI
Motivation
The
UnitTestsHostAppcrashes during launch on iOS 27 with the following error because it doesn't use a scene-based lifecycle:This causes all tests that utilize the
UnitTestsHostAppto crash on iOS 27.Description
Updates the
UnitTestsHostAppto use a scene-based app lifecycle.Note
Low Risk
Test-only host app launch plumbing; no production app or SDK runtime behavior changes.
Overview
UnitTestsHostApp on iOS (the
#elsebranch that keeps anAppDelegatefor pre–scene APIs) now adopts UIScene so the host can launch on SDKs that require a scene lifecycle (e.g. iOS 27).AppDelegateimplementsapplication(_:configurationForConnecting:options:)and returns a defaultUISceneConfigurationwhose delegate is a newSceneDelegate.SceneDelegatebuilds the window and setsUIHostingController(rootView: Text("Hello World"))—the same placeholder UI the host needed before.Info.plist adds
UIApplicationSceneManifestwithUIApplicationSupportsMultipleScenesset to false.Reviewed by Cursor Bugbot for commit 8948e10. Bugbot is set up for automated code reviews on this repo. Configure here.