Skip to content

iOS / tvOS: adopt the UIScene lifecycle (apps crash at launch on iOS / tvOS 27) - #8643

Merged
danoli3 merged 3 commits into
openframeworks:masterfrom
danoli3:ios-uiscene-lifecycle
Nov 2, 2026
Merged

danoli3 merged 3 commits into
openframeworks:masterfrom
danoli3:ios-uiscene-lifecycle

Conversation

@danoli3

@danoli3 danoli3 commented Nov 1, 2026

Copy link
Copy Markdown
Member

Fixes #8639.

On iOS 27 and tvOS 27, UIKit stops every app that hasn't adopted the UIScene lifecycle at launch, before setup():

EXC_BREAKPOINT … UIKitCore`___UIApplicationEvaluateRuntimeIssueForNoSceneLifecycleAdoption_block_invoke

ofxiOS still used the app-delegate lifecycle from before iOS 13, so no openFrameworks iOS or tvOS app could start on them.

Change

  • ofxiOSSceneDelegate (in ofAppiOSWindow.mm, which builds for iOS and tvOS, so no project files change):
    • When the scene connects, it attaches the window the app delegate already created in applicationDidFinishLaunching: (window.windowScene = scene) and shows it.
    • It forwards sceneDidBecomeActive / sceneWillResignActive / sceneWillEnterForeground / sceneDidEnterBackground to the app delegate's applicationDidBecomeActive: etc. UIKit no longer calls those in scene-based apps, and ofxiOS uses them for focus, animation and glFinish().
    • It forwards opened URLs (scene:openURLContexts:, including the launch URL) to application:openURL:options:, or on iOS to application:handleOpenURL:.
  • Template Info.plists (scripts/templates/ios/ofxiOS-Info.plist, scripts/templates/tvOS/ofxtvOS-Info.plist): a single-scene UIApplicationSceneManifest that names ofxiOSSceneDelegate. Naming it in the plist, rather than returning it from the app delegate, means it also works with custom app delegates (ofAppiOSWindow::startAppWithDelegate) that don't subclass ofxiOSAppDelegate.

ofxiOSAppDelegate, ofxtvOSAppDelegate and their subclasses are unchanged. They still create the window and view controller in applicationDidFinishLaunching:.

Existing projects keep their own ofxiOS-Info.plist / ofxtvOS-Info.plist, so they need the same UIApplicationSceneManifest entry added to run on iOS / tvOS 27.

Tested

Xcode 27.1 on the iOS 27.2 and tvOS 27.2 Simulators. I built each template's app with CMake, switching windowControllerType between GLKit and Core Animation, and rebuilt the core with this change:

Template Controller Launch setup() / first draw() Screen
ios GL_KIT ✅ running after 20 s ✅ / ✅ 1398×2034 ✅ full screen, no status bar
ios CORE_ANIMATION ✅ ✅ / ✅ 1398×2034 ✅
tvOS GL_KIT ✅ ✅ / ✅ ✅ full screen
tvOS CORE_ANIMATION ✅ ✅ / ✅ ✅

Before the change, both templates stopped at launch with the EXC_BREAKPOINT above.

Not tested here:

  • a custom app delegate, external displays, and URL opening;
  • devices (Simulators only), and iOS / tvOS 26 and earlier.

The scene APIs exist since iOS / tvOS 13, so older versions should run the same code.

Separate, maybe existing: on tvOS, ofGetWidth() / ofGetHeight() report 1080 × 1920 (portrait) while the app correctly fills the 1920 × 1080 screen. No tvOS 27 app could run before this change, so I couldn't compare. ofxiOS's orientation handling treats tvOS like a portrait device, so it's probably not new, but it's worth checking.

…/ tvOS 27)

Fixes openframeworks#8639. ofxiOSSceneDelegate (ofAppiOSWindow.mm) attaches the window the app delegate already creates in applicationDidFinishLaunching: to the connecting UIWindowScene, and forwards the scene's active / resign / background / foreground events and opened URLs to the app delegate's existing methods. The iOS and tvOS template Info.plists name it in UIApplicationSceneManifest. App delegates, including ones started with startAppWithDelegate, are unchanged.
Removed deprecated URL handling for tvOS.
@danoli3
danoli3 merged commit 421c02d into openframeworks:master Nov 2, 2026
2 checks passed
@ofTheo

ofTheo commented Nov 4, 2026

Copy link
Copy Markdown
Member

Looks like this broke on tvOS.
https://github.com/openframeworks/openFrameworks/actions/runs/41420777902/job/125196163582?pr=8643

** BUILD FAILED **


The following build commands failed:
	CompileC /Users/runner/work/openFrameworks/openFrameworks/libs/openFrameworksCompiled/lib/tvos/build/temp/Release/tvOS+OFLib.build/Objects-normal/x86_64/ofAppiOSWindow.o /Users/runner/work/openFrameworks/openFrameworks/addons/ofxiOS/src/app/ofAppiOSWindow.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'tvOS+OFLib' from project 'tvOS+OFLib')
(1 failure)

Should prob wait to merge before all checks are passed.

danoli3 added a commit that referenced this pull request Nov 5, 2026
#8643's ofxiOSSceneDelegate forwards opened URLs to the app delegate.
application:handleOpenURL: is API_UNAVAILABLE(tvos), so tvOS+OFLib
fails on Xcode 27:

  ofAppiOSWindow.mm:93: error: 'application:handleOpenURL:' is unavailable

The first commit of #8643 already skipped that selector with
#if !TARGET_OS_TV; a later commit in the squash dropped the guard.

Restore the guard and implement application:openURL:options: on
ofxtvOSAppDelegate so the scene path still delivers URLs on tvOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS / tvOS 27: apps crash at launch because ofxiOS doesn't use the UIScene lifecycle

2 participants