fix: Flip signs in Time.h's Apple version checks #1688
Closed
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.
When trying to bring react-native-macos up to date with 0.66, I was running into an issue getting RNTester to compile due to an error regarding redefining
clockid_t
. Other people have been seeing similar issues as per these search results.The history behind this appears to be as follows:
Several declarations in
<time.h>
were not available on Apple platforms until macOS 10.12 and iOS 10, which is why Folly needs to check the minimum version and setFOLLY_HAVE_CLOCK_GETTIME
as needed. The problem is, the current logic as it stands right now is to setFOLLY_HAVE_CLOCK_GETTIME = 1
(which implies that we don't need to declare them ourselves as the OS provides them for us) if...However, this doesn't make any sense. This is saying that we don't need to declare these missing APIs if we could be compiling Folly for use on an older version (i.e., macOS 10.11/iOS 9 or earlier), which is totally wrong! Instead, we ought to be checking if the versions are at least macOS 10.12 or iOS 10.
React Native currently works around this by eliminating the minimum version check entirely with this PR, which is certainly a valid local fix (the minimum iOS version for React Native apps is currently iOS 11), but doesn't solve the problem at its core. This PR does solve the problem.
I have not tested building this with a minimum version below the above thresholds for use on a modern version of macOS/iOS, but considering the discussion in #1545, I think we should be safe to ignore these older versions from now on.