Skip to content

Commit

Permalink
fix: ifdef orientation code that requries iOS 16 (#1794)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
kkafar authored Jun 20, 2023
1 parent defec05 commit d712e6e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ios/RNSScreenWindowTraits.mm
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ + (void)enforceDesiredDeviceOrientation
}
}
if (newOrientation != UIInterfaceOrientationUnknown) {
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0
if (@available(iOS 16.0, *)) {
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array[0];
Expand All @@ -191,13 +193,15 @@ + (void)enforceDesiredDeviceOrientation
}

[topController setNeedsUpdateOfSupportedInterfaceOrientations];
} else {
} else
#endif // Check for iOS 16
{
[[UIDevice currentDevice] setValue:@(newOrientation) forKey:@"orientation"];
[UIViewController attemptRotationToDeviceOrientation];
}
}
});
#endif
#endif // !TARGET_TV_OS
}

+ (void)updateWindowTraits
Expand Down

0 comments on commit d712e6e

Please sign in to comment.