Skip to content

Commit 08f1008

Browse files
Fix deprecated interfaceOrientation on iOS 26
Use effectiveGeometry.interfaceOrientation on iOS 26+ while keeping the old interfaceOrientation call for earlier iOS versions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 11a5d4d commit 08f1008

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • Dependencies/xr/Source/ARKit

Dependencies/xr/Source/ARKit/XR.mm

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,24 @@ - (void) UnlockAnchors {
259259
- (UIInterfaceOrientation)orientation {
260260
UIApplication* sharedApplication = [UIApplication sharedApplication];
261261
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_13_0)
262-
UIScene* scene = [[[sharedApplication connectedScenes] allObjects] firstObject];
263-
return [(UIWindowScene*)scene interfaceOrientation];
262+
UIWindowScene* windowScene = (UIWindowScene*)[[[sharedApplication connectedScenes] allObjects] firstObject];
263+
if (@available(iOS 26.0, *)) {
264+
return windowScene.effectiveGeometry.interfaceOrientation;
265+
}
266+
#pragma clang diagnostic push
267+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
268+
return [windowScene interfaceOrientation];
269+
#pragma clang diagnostic pop
264270
#else
265271
if (@available(iOS 13.0, *)) {
266-
return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation];
272+
UIWindowScene* windowScene = [[[sharedApplication windows] firstObject] windowScene];
273+
if (@available(iOS 26.0, *)) {
274+
return windowScene.effectiveGeometry.interfaceOrientation;
275+
}
276+
#pragma clang diagnostic push
277+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
278+
return [windowScene interfaceOrientation];
279+
#pragma clang diagnostic pop
267280
}
268281
else {
269282
return [sharedApplication statusBarOrientation];

0 commit comments

Comments
 (0)