beeware / beeware/toga

Integration with SceneDelegate on iOS [iOS 26+ deprecation]

Open
#3,956 8 comments 0 reactions 0 assignees View on GitHub
enhancement iOS
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
9h 45m
Merged PRs (30d)
58

Description

### What is the problem or limitation you are having?

The initWithFrame method of UIWindow is deprecated in iOS 26; in addition, it does not play well with multiwindowing on iPadOS where we do not nessacarily know the frame of the overall window.

UIScenes manage one instance of your application interface -- so i.e. if you have 2 windows of an app open on an iPad, it's 2 UIScenes. We should setup a UISceneDelegate in Toga and the application template (like we currently put PythonAppDelegate in the template) to create UI -- and then we enforce 1 window per Scene instead of one window per app.

Deprecation -- these APIs are actually going away the next version, in 1 year -- so we have to cook up a solution really quick: https://developer.apple.com/documentation/uikit/uiwindow/init(frame:)?language=objc

### Describe the solution you'd like

This isn't really clear. It's like #1803 but for iOS, but the multiple scenes can exist *in parallel*. So enforcing 1 window per scene is not easy -- if scenes map to Apps, you can't really have 2 apps (since toga.App.app will then break) -- for #1803 there are 2 App instances, but each time a new one is created, the previous one just exists for the sake of it and isn't really visible anymore.

Still one window per scene though, since creating more UIWindows can't really create more physical windows in the sense of iPadOS.

Figure out how to force minimum sizes for windows and use that in container refreshed. Stop assuming window size only changes on rotation and use the relevant method on UISceneDelegate to do these kind of stuff.

(perhaps) remove top status bar references from top_offset? I don't know how multiwindowing manages these stuff though.

### Describe alternatives you've considered

There's no way. if we leave this as-is, Toga will be unusable on iOS in 1 year. This is an existiential threat to Toga.

### Additional context

This method was only deprecated this year. Perhaps we should figure out some sort of way to parse headers to notify us about depreactions as part of rubicon-objc? Because ObjCClass will still show the method and we still used it without warnings in Toga as of now.

But note that the new approach with window scenes existed since iOS 13+ -- perhaps we should bump minimum version for Toga to iOS 13.

sidenote

iOS 13... I remember sitting on a sofa from 6 or 7 years ago back in China when our old iPhone 6 is stuck in iOS 12 and was trying to install a chatting app... and we had to upgrade. Yak shaving, I guess...

Contributor guide

Open the contributing guide

Research direction

Review Toga's existing iOS application and window setup, including the PythonAppDelegate template, then compare it with the UISceneDelegate lifecycle described in the issue. Define how one UIWindow maps to each scene, how minimum sizes and window refresh behavior should work, and what iOS behavior demonstrates that the migration is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, python
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.