Skip to content

fix(ios): Adopt the UIKit scene life cycle (6.8) - #25688

Merged
agneszitte merged 9 commits into
unoplatform:servicing/6.8from
ajpinedam:dev/anpi/fix.ios.scene.lifecycle
Nov 17, 2026
Merged

agneszitte merged 9 commits into
unoplatform:servicing/6.8from
ajpinedam:dev/anpi/fix.ios.scene.lifecycle

Conversation

@ajpinedam

@ajpinedam ajpinedam commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25510

PR Type:

🐞 Bugfix

What changed? 🚀

Apps built with the version 27 SDKs (Xcode 27) must use the UIKit scene lifecycle, or iOS 27 refuses to launch them: UIScene life cycle is required for apps built with this SDK. Uno 6.8 only runs the app lifecycle, so every 6.8 app built with Xcode 27 crashes at launch. Thanks to @mikernet for the report and the proposal this follows.

This PR makes 6.8 adopt the scene lifecycle on the app's behalf, for both Skia and native rendering, with no scene manifest needed:

  • When it applies:
    • By default when the app is built with a version 27 SDK or later, or when the SDK version can't be read.
    • The UnoUseSceneLifecycle Info.plist key overrides the default in either direction.
    • Apps built with an older SDK keep the app lifecycle: the notification filtering and visibility handling below only apply under the scene lifecycle. The one change for them is an application delegate that overrides GetConfiguration (see the end of this description).
    • An app that declares its own UIApplicationSceneManifest keeps it. Uno only assigns its scene delegate to an application scene configuration that declares no delegate class.
  • How it works:
    • The application delegate implements GetConfiguration, which is what makes UIKit switch to the scene lifecycle, and assigns the new internal UnoUISceneDelegate to the application scene. It hides that selector when the app stays on the app lifecycle.
    • The scene delegate hosts the app's window in the scene. One file is shared by the native (Application) and Skia (UnoUIApplicationDelegate) delegates.
    • The scene delegate is registered in Objective-C as UnoAdoptedSceneDelegate, the same name as the master fix (fix(ios): Adopt the scene lifecycle without a manifest #25687), so an app updated from 6.8 to 7.0 gets its saved scene session restored with the right delegate.
    • Which lifecycle the app runs is logged at startup. A warning is logged when UnoUseSceneLifecycle is neither a boolean nor a number, or the SDK version is unknown.
  • Application delegate overrides: UIKit now sends the URL, user activity, shortcut, and foreground/background callbacks to the scene delegate, which forwards each one to the application delegate when it implements it. Overrides such as OpenUrl, ContinueUserActivity, PerformActionForShortcutItem, OnActivated and DidEnterBackground keep working. A failing callback is logged with its name and raised as an unhandled exception, and a shortcut's completion handler runs once.
    • The native Application.PerformActionForShortcutItem now calls its completion handler. It never did, under either lifecycle, so with native rendering a forwarded shortcut was never completed. The docs now say that an override calling base must not call the handler again. The Skia application delegate still doesn't implement shortcuts, as before.
  • Launch: the app still launches from FinishedLaunching, for both renderers. Under the scene lifecycle, UIKit delivers the URL, user activity or shortcut the app was launched with once the scene connects.
    • With native rendering, a cold start from a URL or universal link now gives OnLaunched, then OnActivated with a PreviousExecutionState of Running, instead of OnActivated alone.
    • A cold start from a shortcut gives a plain OnLaunched, then one carrying the shortcut's arguments.
  • Uno.Sdk minimum OS version: the iOS 27 SDK requires iOS 15.0, while the Uno.Sdk defaults to 14.2, so the build failed. When the app doesn't set SupportedOSPlatformVersion and the workload requires a higher minimum, the Uno.Sdk now uses the workload's minimum and says so in the build output. A version the app sets is kept.
  • Tests:
    • New runtime test Given_Window.When_Scene_Lifecycle_Window_Hosted_In_Application_Scene. It's inconclusive under the app lifecycle. It fails if its reflection lookup of UsesSceneLifecycle finds nothing, for instance once trimmed, instead of carrying on as if the app used the scene lifecycle.
    • The Skia iOS SamplesApp sets UnoUseSceneLifecycle, so the new test runs under the scene lifecycle in CI. CI builds with Xcode 26.1.1, where the default is the app lifecycle, and runs no native iOS tests. CI therefore no longer covers the default app lifecycle path. The native SamplesApp keeps the default for its SDK.
    • The lifecycle decision is split out into AppleUIKitLifecycleDecision.Decide(hasSceneManifest, useSceneLifecycle, sdkVersion), the same shape as on master. New unit tests Given_AppleUIKitLifecycleDecision run master's cases plus SDK 26 and 26.1: a scene manifest, the key set to true, false or unset, and 26.x, 27+, unreadable or missing SDK versions.
    • On the Skia iOS SamplesApp, the new runtime test fails instead of going inconclusive if the app runs the app lifecycle, so losing the opt-in can't silently drop the coverage. The SamplesApp now logs which lifecycle runs and why.
  • Docs:
    • customizing-uiapplicationdelegate.md: new Scene life cycle section, including the remaining differences and the startup log.
    • using-the-uno-sdk.md: the minimum OS version rule, and a Mac Catalyst row in the defaults table.

The master counterpart is #25687, which fixes the same crash for apps without a scene manifest on top of master's scene support.

Validation

All runtime checks ran on simulators with Xcode 27.1.

  • After the review fixes (this branch rebased on servicing/6.8 08e60ff):

    • Unit tests: Given_AppleUIKitLifecycleDecision, 19 cases, pass. Changing >= 27 to > 27 made the 27 cases fail.
    • Skia SamplesApp, iOS 26.5, with the key: Given_Window has no failures, and the scene test passes instead of going inconclusive. The startup log reads Running the scene life cycle (scene manifest: False, UnoUseSceneLifecycle: true, SDK version: 27.1).
    • The same app with the key set to false: the app lifecycle runs, and the scene test fails on the Skia iOS assertion.
    • Native rendering, Release, device registrar: a native template app (6.8.0-dev.187 packages, with this branch's Uno.UI, Uno, Uno.Foundation, Uno.UI.Composition and Uno.UI.Dispatching), built for the simulator in Release with Registrar=managed-static, which iOS 27.1 device builds use. On iOS 27 it renders its page, and its scene's delegate is UnoAdoptedSceneDelegate, hosting the key window. The app was started with UIApplication.Main(args, null, typeof(App)) rather than the host builder, for a reason unrelated to this PR.
    • Compile: the native Uno.UI builds in Release with analyzers on, for net9.0-ios and net10.0-ios. The Skia SamplesApp builds too. The native SamplesApp doesn't build on servicing/6.8 itself (CS0260 and CS0234 in Uno.UI.RuntimeTests), with or without this PR.
    • Shortcut completion: checked by code review and compile only. A Home Screen quick action can't be triggered from a script on the simulator.
  • Compile:

    • The Skia SamplesApp (net9.0-ios) and the native Uno.UI (net10.0-ios) build.
    • The Skia runtime, which also compiles the shared scene delegate, builds clean with analyzers and code-style enforcement on.
  • Runtime, the current code:

    • Skia SamplesApp, iOS 27, default settings: the app runs the scene lifecycle, since it's built with the 27 SDK, and Given_Window has no failures, the new test included.
    • Skia SamplesApp, iOS 26.5, UnoUseSceneLifecycle=false: the app lifecycle path. Given_Window has no failures and the new test is inconclusive.
    • Skia SamplesApp, iOS 26.5, default settings: scene lifecycle, no failures.
    • Round trips: a background/foreground round trip keeps the process with both renderers, and the Skia SamplesApp logs OnSuspending, then OnResuming.
    • Startup log: a non-boolean UnoUseSceneLifecycle logs its warning.
    • Upgrade to master: installing the master fix over this build restores the saved scene session.
    • Native template app, iOS 27: built with stock 6.8 plus this branch's Uno.UI.dll, it launches through OnLaunched and renders.
  • Runtime, the earlier test plan (run before the native launch was changed to start immediately):

    • Skia SamplesApp: the new test passes with the key set to true and with it removed. With false, iOS refuses to launch the app, as UIKit requires.
    • Template apps (Skia and native): stock 6.8 builds fail to launch with the scene lifecycle error, and the same apps with this branch's assemblies launch and render.
    • Uno.Sdk: building with the stock Uno.Sdk fails on the minimum OS version. With this branch's targets the build succeeds with 15.0.
    • iPad: the new test passes.

Not validated yet

  • Native URL and shortcut activations since the launch change. A cold start needs a tap on the system's "Open" prompt.
  • tvOS and Mac Catalyst at runtime, and a physical device. The device registrar was only checked on a Release simulator build.
  • CI no longer runs the default app lifecycle that apps built with Xcode 26 get: the Skia head opts in, and servicing/6.8 runs no native iOS tests. The unit tests and local runs cover it.

PR Checklist ✅

No API changes; the new Info.plist key is the one addition. Apart from the GetConfiguration case below, the behavior only changes for apps built with a version 27 SDK, which couldn't launch before. For those, the launch URL, shortcut or user activity is no longer in FinishedLaunching's launch options and arrives after the launch, and the obsolete OpenUrl(app, url, sourceApp, annotation) overload isn't called. Both are documented.

One behavior change also reaches apps built with an older SDK. An application delegate that overrides GetConfiguration, without a scene manifest, used to switch UIKit to the scene lifecycle. Uno now hides that method while the app stays on the app lifecycle, so such an app runs the app lifecycle unless it sets UnoUseSceneLifecycle to true. The docs say so.

@github-actions github-actions Bot added platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Oct 25, 2026
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241261 did not find any UI Test snapshots differences.

@ajpinedam
ajpinedam force-pushed the dev/anpi/fix.ios.scene.lifecycle branch from 19e65f3 to 2479841 Compare October 25, 2026 15:10
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241266 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 241266 has failed on Uno.UI - CI.

@ajpinedam
ajpinedam marked this pull request as ready for review October 26, 2026 11:51
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241386 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 241386 has failed on Uno.UI - CI.

@ramezgerges ramezgerges mentioned this pull request Oct 27, 2026
2 of 5 tasks
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241692 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 241692 has failed on Uno.UI - CI.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 242366 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 244964 did not find any UI Test snapshots differences.

@ajpinedam
ajpinedam force-pushed the dev/anpi/fix.ios.scene.lifecycle branch from 85e1428 to f492645 Compare November 16, 2026 15:45
@mergify

mergify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 246811 did not find any UI Test snapshots differences.

@agneszitte agneszitte 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.

Comments inline.

CI: the branch needs an update from servicing/6.8 ("Update branch" or a rebase) to get #26540 (package diff) and #26547 (docs). A rerun or /azp run still builds the old test merge on the previous base.

Comment thread src/Uno.UI/UI/Xaml/Application.UIKit.cs Resolved
@ajpinedam
ajpinedam force-pushed the dev/anpi/fix.ios.scene.lifecycle branch from f492645 to e5879c8 Compare November 16, 2026 23:56
@ajpinedam

Copy link
Copy Markdown
Contributor Author

Rebased onto servicing/6.8 08e60ff, so CI now includes #26540 and #26547. I answered each inline comment in its thread, and the description lists what was checked.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 246965 did not find any UI Test snapshots differences.

@agneszitte agneszitte 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, all 5 points are addressed. CI is green on the rebased branch: the scene test passes on iOS Skia, and the 19 new unit tests pass. Approving.

@agneszitte
agneszitte merged commit 5b70f67 into unoplatform:servicing/6.8 Nov 17, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation kind/documentation platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants