Skip to content

Adopt scene lifecycle in UnitTestsHostApp for iOS 27 support#6980

Merged
fire-at-will merged 6 commits into
mainfrom
adopt-scene-lifecycle-in-unit-tests-app
Jun 15, 2026
Merged

Adopt scene lifecycle in UnitTestsHostApp for iOS 27 support#6980
fire-at-will merged 6 commits into
mainfrom
adopt-scene-lifecycle-in-unit-tests-app

Conversation

@fire-at-will

@fire-at-will fire-at-will commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Motivation

The UnitTestsHostApp crashes during launch on iOS 27 with the following error because it doesn't use a scene-based lifecycle:

failure in void _UIApplicationEvaluateRuntimeIssueForNoSceneLifecycleAdoption(void)_block_invoke 
(UIApplication_RuntimeIssues.m:106) : Application failed to launch: UIScene life cycle is required for apps 
built with this SDK. See Technote TN3187 for more information on migration.

This causes all tests that utilize the UnitTestsHostApp to crash on iOS 27.

Description

Updates the UnitTestsHostApp to 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 #else branch that keeps an AppDelegate for pre–scene APIs) now adopts UIScene so the host can launch on SDKs that require a scene lifecycle (e.g. iOS 27).

AppDelegate implements application(_:configurationForConnecting:options:) and returns a default UISceneConfiguration whose delegate is a new SceneDelegate. SceneDelegate builds the window and sets UIHostingController(rootView: Text("Hello World"))—the same placeholder UI the host needed before.

Info.plist adds UIApplicationSceneManifest with UIApplicationSupportsMultipleScenes set to false.

Reviewed by Cursor Bugbot for commit 8948e10. Bugbot is set up for automated code reviews on this repo. Configure here.

@fire-at-will fire-at-will requested a review from a team as a code owner June 11, 2026 15:19
@fire-at-will fire-at-will changed the title adopt scene lifecycle in unit tests app for iOS 27 Adopt scene lifecycle in UnitTestsHostApp for iOS 27 support Jun 11, 2026

@fire-at-will fire-at-will Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fire-at-will fire-at-will Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@fire-at-will fire-at-will merged commit 54e2248 into main Jun 15, 2026
43 checks passed
@fire-at-will fire-at-will deleted the adopt-scene-lifecycle-in-unit-tests-app branch June 15, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants