BUG iOS) I found an orientation iOS16 issue in the iOS simulator

When I checked the iOS application that I created, which worked fine until iOS15, with the simulator of iOS16 (in New Xcode 14.0), the orientation of the screen became strange and the following message appeared in the console. (from UIKit?)

[Orientation] BUG IN CLIENT OF UIKIT: Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:slight_smile:

The code for JUCE that seems to apply is
in juce_ios_UIViewComponentPeer.mm
void Desktop::allowedOrientationsChanged()

Please give me suggestions on how to fix it

We have this problem too I’m afraid. Also, it is a problem for iOS16 in general - i.e. on actual devices as well as the simulator. JUCE will need an update to support orientation changes on iOS16.

Here are some details:

In the file juce_ios_UIViewComponentPeer.mm, specifically in the function void Desktop::allowedOrientationsChanged(), the following line…

[[UIDevice currentDevice] setValue:value forKey:@"orientation"];

is now deprecated in iOS16.

Some more info here:
https://developer.apple.com/forums/thread/707735

I have read that the solution may involve calling requestGeometryUpdateWithPreferences on the window scene. So far I’ve been unable to make this work, however.

A fix to this would be greatly appreciated as it breaks orientation support on all devices that update to iOS16.

Thanks in advance,
Adam

Thanks for reporting, the new API is now used on devices running iOS 16+, as long as your app is built using a version of Xcode that includes the iOS SDK 16 or newer.

1 Like

Thank you.
I applied the patch immediately to see how it works, and it works.
I also understand that DeploymentTarget >= iOS16.0 is required to use this patch (UIWindowScene.Geometry is a new API).
From now on, the Apple store will require me to offer multiple OS versions of my app. I don’t understand why Apple does this.

This change should work correctly on iOS 16 and earlier, so there shouldn’t be any need to distribute multiple copies of your app.

I understand what reuk-san is saying even in the source code.

The Xcode’s technique of using a “low DeploymentTarget” to support older OS versions and the latest OS at the same time no longer works. about it.