Skip to content

Commit 398595e

Browse files
ken0nekfacebook-github-bot
authored andcommitted
Remove iOS 11 version check (#32151)
Summary: This pull request aims to remove iOS 11 version check which is no longer needed. The minimum iOS deployment target for React Native is `iOS 11` but we still have iOS 11 version check like below. ``` #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */ if (available(iOS 11.0, *)) { ``` > React Native apps may target iOS 11.0 and Android 5.0 (API 21) or newer. ref: https://github.com/facebook/react-native#-requirements ------ If there is a team motivation to remove the deprecated methods and classes before iOS 10, I can continue the work in this pull request or in the continuing pull requests. We have deprecated warnings for these in the project. - `UIUserNotificationSettings` - `UILocalNotification` - `topLayoutGuide` and `bottomLayoutGuide` - `automaticallyAdjustsScrollViewInsets` ## Changelog [iOS] [Changed] - Remove iOS 11 version check Pull Request resolved: #32151 Reviewed By: sammy-SC Differential Revision: D30877917 Pulled By: yungsters fbshipit-source-id: d903ea5d557beeb65ef87bfce572e4db3532b3c5
1 parent 369b28c commit 398595e

File tree

12 files changed

+21
-89
lines changed

12 files changed

+21
-89
lines changed

Libraries/PushNotificationIOS/RCTPushNotificationManager.mm

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ @implementation RCTPushNotificationManager
103103
return formattedLocalNotification;
104104
}
105105

106-
API_AVAILABLE(ios(10.0))
107106
static NSDictionary *RCTFormatUNNotification(UNNotification *notification)
108107
{
109108
NSMutableDictionary *formattedNotification = [NSMutableDictionary dictionary];

Libraries/Text/TextInput/RCTBaseTextInputView.m

+2-12
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,10 @@ - (void)setTextContentType:(NSString *)type
242242
@"streetAddressLine2": UITextContentTypeStreetAddressLine2,
243243
@"sublocality": UITextContentTypeSublocality,
244244
@"telephoneNumber": UITextContentTypeTelephoneNumber,
245+
@"username": UITextContentTypeUsername,
246+
@"password": UITextContentTypePassword,
245247
};
246248

247-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
248-
if (@available(iOS 11.0, *)) {
249-
NSDictionary<NSString *, NSString *> * iOS11extras = @{@"username": UITextContentTypeUsername,
250-
@"password": UITextContentTypePassword};
251-
252-
NSMutableDictionary<NSString *, NSString *> * iOS11baseMap = [contentTypeMap mutableCopy];
253-
[iOS11baseMap addEntriesFromDictionary:iOS11extras];
254-
255-
contentTypeMap = [iOS11baseMap copy];
256-
}
257-
#endif
258-
259249
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 /* __IPHONE_12_0 */
260250
if (@available(iOS 12.0, *)) {
261251
NSDictionary<NSString *, NSString *> * iOS12extras = @{@"newPassword": UITextContentTypeNewPassword,

Libraries/Text/TextInput/RCTInputAccessoryViewContent.m

+4-11
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,10 @@ - (instancetype)init
3030
_heightConstraint = [_safeAreaContainer.heightAnchor constraintEqualToConstant:0];
3131
_heightConstraint.active = YES;
3232

33-
if (@available(iOS 11.0, *)) {
34-
[_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor].active = YES;
35-
[_safeAreaContainer.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor].active = YES;
36-
[_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor].active = YES;
37-
[_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor].active = YES;
38-
} else {
39-
[_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.bottomAnchor].active = YES;
40-
[_safeAreaContainer.topAnchor constraintEqualToAnchor:self.topAnchor].active = YES;
41-
[_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.leadingAnchor].active = YES;
42-
[_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.trailingAnchor].active = YES;
43-
}
33+
[_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor].active = YES;
34+
[_safeAreaContainer.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor].active = YES;
35+
[_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor].active = YES;
36+
[_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor].active = YES;
4437
}
4538
return self;
4639
}

React/Base/RCTConvert.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef NSURL RCTFileURL;
7474
#endif
7575

7676
#if TARGET_OS_IPHONE
77-
+ (WKDataDetectorTypes)WKDataDetectorTypes:(id)json API_AVAILABLE(ios(10.0));
77+
+ (WKDataDetectorTypes)WKDataDetectorTypes:(id)json;
7878
#endif
7979

8080
+ (UIViewContentMode)UIViewContentMode:(id)json;

React/CoreModules/RCTDevLoadingView.mm

+3-10
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,9 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
114114
if (!self->_window && !RCTRunningInTestEnvironment()) {
115115
CGSize screenSize = [UIScreen mainScreen].bounds.size;
116116

117-
if (@available(iOS 11.0, *)) {
118-
UIWindow *window = RCTSharedApplication().keyWindow;
119-
self->_window =
120-
[[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 10)];
121-
self->_label =
122-
[[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, screenSize.width, 20)];
123-
} else {
124-
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 20)];
125-
self->_label = [[UILabel alloc] initWithFrame:self->_window.bounds];
126-
}
117+
UIWindow *window = RCTSharedApplication().keyWindow;
118+
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 10)];
119+
self->_label = [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, screenSize.width, 20)];
127120
[self->_window addSubview:self->_label];
128121

129122
self->_window.windowLevel = UIWindowLevelStatusBar + 1;

React/CoreModules/RCTRedBox.mm

+1-5
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,7 @@ - (UIButton *)redBoxButton:(NSString *)title
201201

202202
- (NSInteger)bottomSafeViewHeight
203203
{
204-
if (@available(iOS 11.0, *)) {
205-
return RCTSharedApplication().delegate.window.safeAreaInsets.bottom;
206-
} else {
207-
return 0;
208-
}
204+
return RCTSharedApplication().delegate.window.safeAreaInsets.bottom;
209205
}
210206

211207
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)

React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

+1-5
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
331331

332332
// `accessibilityIgnoresInvertColors`
333333
if (oldViewProps.accessibilityIgnoresInvertColors != newViewProps.accessibilityIgnoresInvertColors) {
334-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
335-
if (@available(iOS 11.0, *)) {
336-
self.accessibilityIgnoresInvertColors = newViewProps.accessibilityIgnoresInvertColors;
337-
}
338-
#endif
334+
self.accessibilityIgnoresInvertColors = newViewProps.accessibilityIgnoresInvertColors;
339335
}
340336

341337
// `accessibilityValue`

React/Views/RCTView.m

+1-6
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,7 @@ - (NSString *)accessibilityValue
276276

277277
if (bundle) {
278278
NSURL *url = [bundle URLForResource:@"Localizable" withExtension:@"strings"];
279-
if (@available(iOS 11.0, *)) {
280-
rolesAndStatesDescription = [NSDictionary dictionaryWithContentsOfURL:url error:nil];
281-
} else {
282-
// Fallback on earlier versions
283-
rolesAndStatesDescription = [NSDictionary dictionaryWithContentsOfURL:url];
284-
}
279+
rolesAndStatesDescription = [NSDictionary dictionaryWithContentsOfURL:url error:nil];
285280
}
286281
if (rolesAndStatesDescription == nil) {
287282
// Falling back to hardcoded English list.

React/Views/SafeAreaView/RCTSafeAreaView.m

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,9 @@ - (BOOL)isSupportedByOS
5252

5353
- (UIEdgeInsets)safeAreaInsetsIfSupportedAndEnabled
5454
{
55-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
5655
if (self.isSupportedByOS) {
57-
if (@available(iOS 11.0, *)) {
58-
return self.safeAreaInsets;
59-
}
56+
return self.safeAreaInsets;
6057
}
61-
#endif
6258
return self.emulateUnlessSupported ? self.emulatedSafeAreaInsets : UIEdgeInsetsZero;
6359
}
6460

React/Views/ScrollView/RCTScrollView.m

+5-15
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,8 @@ - (void)setFrame:(CGRect)frame
197197
if (CGSizeEqualToSize(contentSize, CGSizeZero)) {
198198
self.contentOffset = originalOffset;
199199
} else {
200-
if (@available(iOS 11.0, *)) {
201-
if (!UIEdgeInsetsEqualToEdgeInsets(UIEdgeInsetsZero, self.adjustedContentInset)) {
202-
contentInset = self.adjustedContentInset;
203-
}
200+
if (!UIEdgeInsetsEqualToEdgeInsets(UIEdgeInsetsZero, self.adjustedContentInset)) {
201+
contentInset = self.adjustedContentInset;
204202
}
205203
CGSize boundsSize = self.bounds.size;
206204
CGFloat xMaxOffset = contentSize.width - boundsSize.width + contentInset.right;
@@ -287,17 +285,13 @@ - (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDis
287285
_scrollView.delegate = self;
288286
_scrollView.delaysContentTouches = NO;
289287

290-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
291288
// `contentInsetAdjustmentBehavior` is only available since iOS 11.
292289
// We set the default behavior to "never" so that iOS
293290
// doesn't do weird things to UIScrollView insets automatically
294291
// and keeps it as an opt-in behavior.
295292
if ([_scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
296-
if (@available(iOS 11.0, *)) {
297-
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
298-
}
293+
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
299294
}
300-
#endif
301295

302296
_automaticallyAdjustContentInsets = YES;
303297
_contentInset = UIEdgeInsetsZero;
@@ -940,19 +934,15 @@ - (void)setAutomaticallyAdjustsScrollIndicatorInsets:(BOOL)automaticallyAdjusts
940934
}
941935
#endif
942936

943-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
944-
- (void)setContentInsetAdjustmentBehavior:(UIScrollViewContentInsetAdjustmentBehavior)behavior API_AVAILABLE(ios(11.0))
937+
- (void)setContentInsetAdjustmentBehavior:(UIScrollViewContentInsetAdjustmentBehavior)behavior
945938
{
946939
// `contentInsetAdjustmentBehavior` is available since iOS 11.
947940
if ([_scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
948941
CGPoint contentOffset = _scrollView.contentOffset;
949-
if (@available(iOS 11.0, *)) {
950-
_scrollView.contentInsetAdjustmentBehavior = behavior;
951-
}
942+
_scrollView.contentInsetAdjustmentBehavior = behavior;
952943
_scrollView.contentOffset = contentOffset;
953944
}
954945
}
955-
#endif
956946

957947
- (void)sendScrollEventWithName:(NSString *)eventName
958948
scrollView:(UIScrollView *)scrollView

React/Views/ScrollView/RCTScrollViewManager.m

-7
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ @implementation RCTConvert (UIScrollView)
3636
UIScrollViewIndicatorStyleDefault,
3737
integerValue)
3838

39-
#pragma clang diagnostic push
40-
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
41-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
4239
RCT_ENUM_CONVERTER(
4340
UIScrollViewContentInsetAdjustmentBehavior,
4441
(@{
@@ -49,8 +46,6 @@ @implementation RCTConvert (UIScrollView)
4946
}),
5047
UIScrollViewContentInsetAdjustmentNever,
5148
integerValue)
52-
#endif
53-
#pragma clang diagnostic pop
5449

5550
@end
5651

@@ -105,9 +100,7 @@ - (UIView *)view
105100
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */
106101
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustsScrollIndicatorInsets, BOOL)
107102
#endif
108-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
109103
RCT_EXPORT_VIEW_PROPERTY(contentInsetAdjustmentBehavior, UIScrollViewContentInsetAdjustmentBehavior)
110-
#endif
111104

112105
// overflow is used both in css-layout as well as by react-native. In css-layout
113106
// we always want to treat overflow as scroll but depending on what the overflow

React/Views/UIView+React.m

+2-11
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,12 @@ - (void)setNativeID:(NSString *)nativeID
4747

4848
- (BOOL)shouldAccessibilityIgnoresInvertColors
4949
{
50-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
51-
if (@available(iOS 11.0, *)) {
52-
return self.accessibilityIgnoresInvertColors;
53-
}
54-
#endif
55-
return NO;
50+
return self.accessibilityIgnoresInvertColors;
5651
}
5752

5853
- (void)setShouldAccessibilityIgnoresInvertColors:(BOOL)shouldAccessibilityIgnoresInvertColors
5954
{
60-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
61-
if (@available(iOS 11.0, *)) {
62-
self.accessibilityIgnoresInvertColors = shouldAccessibilityIgnoresInvertColors;
63-
}
64-
#endif
55+
self.accessibilityIgnoresInvertColors = shouldAccessibilityIgnoresInvertColors;
6556
}
6657

6758
- (BOOL)isReactRootView

0 commit comments

Comments
 (0)