feat: add conditionals for iOS only code in RCTDeviceInfo.mm
#45176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Having React Native support every Apple platform is tough to achieve as it introduces many platform-specific ifdefs.
On the other side, maintaining an OOT platform fork is already a demanding job, so to make it easier I propose adding ifdefs for iOS-specific code. Thanks to this change, OOT platforms can focus on their OS-specific features while the core is also adding iOS-specific features behind ifdefs. Fortunately, most of the code on Apple platforms can be shared and this PR aims to introduce better support for this and to minimize OOT fork's surface.
In this example
RCTDeviceInfo.mm
has support for handling orientation changes and the availability of this feature across Apple OS looks as follows:Here is a table from
TargetConditionals.h
header file which shows the coverage ofTARGET_OS_IOS
macro. (It supports both iOS and iPadOS)Changelog:
[INTERNAL] [ADDED] - Conditionals for iOS only code in RCTDeviceInfo.mm
Test Plan:
CI Green