Skip to content

Commit d712e6e

Browse files
authored
fix: ifdef orientation code that requries iOS 16 (#1794)
## Description Currently when XCode w/o support for iOS 16 is used the RNSScreens compilation will most surely fail due to unrecognized symbols being present in the `RNSScreenWindowTraints` code. See [this discussion](#1732 (comment)). ## Changes Added compilation guards for iOS sdk version. When not present old implementation is used. ## Test code and steps to reproduce See #1732 & try to compile & test on different major versions of xcode (e.g. 12 & 14) ## Checklist - [ ] Ensured that CI passes
1 parent defec05 commit d712e6e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ios/RNSScreenWindowTraits.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ + (void)enforceDesiredDeviceOrientation
174174
}
175175
}
176176
if (newOrientation != UIInterfaceOrientationUnknown) {
177+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \
178+
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0
177179
if (@available(iOS 16.0, *)) {
178180
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
179181
UIWindowScene *scene = (UIWindowScene *)array[0];
@@ -191,13 +193,15 @@ + (void)enforceDesiredDeviceOrientation
191193
}
192194

193195
[topController setNeedsUpdateOfSupportedInterfaceOrientations];
194-
} else {
196+
} else
197+
#endif // Check for iOS 16
198+
{
195199
[[UIDevice currentDevice] setValue:@(newOrientation) forKey:@"orientation"];
196200
[UIViewController attemptRotationToDeviceOrientation];
197201
}
198202
}
199203
});
200-
#endif
204+
#endif // !TARGET_TV_OS
201205
}
202206

203207
+ (void)updateWindowTraits

0 commit comments

Comments
 (0)