Skip to content

Commit

Permalink
Move min ios version to 13.4 for OSS (#36795)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #36795

This change bump the min iOS version for React Native to 13.4, to align with company guidelines.

## Changelog:
[iOS][Changed] - Moved the min iOS version to 13.4

Reviewed By: cortinico

Differential Revision: D44634663

fbshipit-source-id: 035e8fcbb395f7394f8253e3ec485ad9937531c2
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Apr 6, 2023
1 parent 03e7801 commit 610b14e
Show file tree
Hide file tree
Showing 80 changed files with 330 additions and 554 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/actionsheetios"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }

This comment has been minimized.

Copy link
@stevenpetryk

stevenpetryk Jul 29, 2024

I want to point out that having these podspecs depend on function defined in another podspec breaks CocoaPods commands that inspect single podspecs. For example, if you run:

pod ipc spec packages/react-native/Libraries/ActionSheetIOS/React-RCTActionSheet.podspec

CocoaPods fails with a NoMethodError on min_ios_version_supported.

When this was done, I think a require_relative should have been added to these podspecs to ensure the method is defined before it's referenced. It's odd, in general, to make some podspecs depend on the alterations to the global namespace caused by another.

This comment has been minimized.

Copy link
@stevenpetryk

stevenpetryk Jul 29, 2024

At Discord we ended up doing this to our fork to get around it: discord@98c7077

@cortinico @cipolleschi would love your thoughts on whether we should upstream this :)

This comment has been minimized.

Copy link
@cipolleschi

cipolleschi Jul 30, 2024

Author Contributor

@stevenpetryk thanks for chiming into this.
We know that this approach is 'dirty' and it relies on the fact that the podspecs are evaluated during pod install.

We can definitely add the require relative, but that could break many monorepo setups where relative paths are not respected as the monorepo will change the paths of the files. I have seen multiple issues related to relative path breaking monorepo setups, so I'm a bit concerned about upstreaming that.

s.source = source
s.source_files = "*.{m}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
Expand Down
7 changes: 2 additions & 5 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
enableFabric = self.fabricEnabled;
#endif
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}

rootView.backgroundColor = [UIColor systemBackgroundColor];

return rootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/actionsheetios"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.source_files = "**/*.{c,h,m,mm,S,cpp}"

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{h,m,mm}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.header_dir = "FBLazyVector"
Expand Down
12 changes: 4 additions & 8 deletions packages/react-native/Libraries/Image/RCTImageView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,11 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
selector:@selector(clearImageIfDetached)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if (@available(iOS 13.0, *)) {
[center addObserver:self
selector:@selector(clearImageIfDetached)
[center addObserver:self
selector:@selector(clearImageIfDetached)

name:UISceneDidEnterBackgroundNotification
object:nil];
}
#endif
name:UISceneDidEnterBackgroundNotification
object:nil];
}
return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/image"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/linking"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "**/*.{h,m,mm}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/pushnotificationios"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.header_dir = "RCTRequired"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/settings"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Text/React-RCTText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/text"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.source_files = "**/*.{h,m}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ - (void)paste:(id)sender
}

// Turn off scroll animation to fix flaky scrolling.
// This is only necessary for iOS <= 13.
// This is only necessary for iOS <= 14.
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < 140000
- (void)setContentOffset:(CGPoint)contentOffset animated:(__unused BOOL)animated
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,13 @@ - (void)setTextContentType:(NSString *)type
@"password" : UITextContentTypePassword,
};

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 /* __IPHONE_12_0 */
if (@available(iOS 12.0, *)) {
NSDictionary<NSString *, NSString *> *iOS12extras =
@{@"newPassword" : UITextContentTypeNewPassword, @"oneTimeCode" : UITextContentTypeOneTimeCode};
NSDictionary<NSString *, NSString *> *iOS12extras =
@{@"newPassword" : UITextContentTypeNewPassword, @"oneTimeCode" : UITextContentTypeOneTimeCode};

NSMutableDictionary<NSString *, NSString *> *iOS12baseMap = [contentTypeMap mutableCopy];
[iOS12baseMap addEntriesFromDictionary:iOS12extras];
NSMutableDictionary<NSString *, NSString *> *iOS12baseMap = [contentTypeMap mutableCopy];
[iOS12baseMap addEntriesFromDictionary:iOS12extras];

contentTypeMap = [iOS12baseMap copy];
}
#endif
contentTypeMap = [iOS12baseMap copy];
});

// Setting textContentType to an empty string will disable any
Expand All @@ -282,11 +278,7 @@ - (void)setTextContentType:(NSString *)type

- (void)setPasswordRules:(NSString *)descriptor
{
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0
if (@available(iOS 12.0, *)) {
self.backedTextInputView.passwordRules = [UITextInputPasswordRules passwordRulesWithDescriptor:descriptor];
}
#endif
self.backedTextInputView.passwordRules = [UITextInputPasswordRules passwordRulesWithDescriptor:descriptor];
}

- (UIKeyboardType)keyboardType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.header_dir = "RCTTypeSafety"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.documentation_url = "https://reactnative.dev/docs/vibration"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.resource_bundle = { "AccessibilityResources" => ["React/AccessibilityResources/*.lproj"]}
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.cocoapods_version = ">= 1.10.1"
Expand Down
38 changes: 15 additions & 23 deletions packages/react-native/React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -959,31 +959,23 @@ + (UIColor *)UIColor:(id)json
id highContrastDark = [appearances objectForKey:@"highContrastDark"];
UIColor *highContrastDarkColor = [RCTConvert UIColor:highContrastDark];
if (lightColor != nil && darkColor != nil) {
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if (@available(iOS 13.0, *)) {
UIColor *color = [UIColor colorWithDynamicProvider:^UIColor *_Nonnull(
UITraitCollection *_Nonnull collection) {
if (collection.userInterfaceStyle == UIUserInterfaceStyleDark) {
if (collection.accessibilityContrast == UIAccessibilityContrastHigh && highContrastDarkColor != nil) {
return highContrastDarkColor;
} else {
return darkColor;
}
UIColor *color = [UIColor colorWithDynamicProvider:^UIColor *_Nonnull(UITraitCollection *_Nonnull collection) {
if (collection.userInterfaceStyle == UIUserInterfaceStyleDark) {
if (collection.accessibilityContrast == UIAccessibilityContrastHigh && highContrastDarkColor != nil) {
return highContrastDarkColor;
} else {
if (collection.accessibilityContrast == UIAccessibilityContrastHigh && highContrastLightColor != nil) {
return highContrastLightColor;
} else {
return lightColor;
}
return darkColor;
}
}];
return color;
} else {
#endif
return lightColor;
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
}
#endif
} else {
if (collection.accessibilityContrast == UIAccessibilityContrastHigh && highContrastLightColor != nil) {
return highContrastLightColor;
} else {
return lightColor;
}
}
}];
return color;

} else {
RCTLogConvertError(json, @"a UIColor. Expected an iOS dynamic appearance aware color.");
return nil;
Expand Down
22 changes: 9 additions & 13 deletions packages/react-native/React/CoreModules/RCTAccessibilityManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,15 @@ static void setMultipliers(
: (NSString *)announcement options
: (JS::NativeAccessibilityManager::SpecAnnounceForAccessibilityWithOptionsOptions &)options)
{
if (@available(iOS 11.0, *)) {
NSMutableDictionary<NSString *, NSNumber *> *attrsDictionary = [NSMutableDictionary new];
if (options.queue()) {
attrsDictionary[UIAccessibilitySpeechAttributeQueueAnnouncement] = @(*(options.queue()) ? YES : NO);
}

if (attrsDictionary.count > 0) {
NSAttributedString *announcementWithAttrs = [[NSAttributedString alloc] initWithString:announcement
attributes:attrsDictionary];
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcementWithAttrs);
} else {
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcement);
}
NSMutableDictionary<NSString *, NSNumber *> *attrsDictionary = [NSMutableDictionary new];
if (options.queue()) {
attrsDictionary[UIAccessibilitySpeechAttributeQueueAnnouncement] = @(*(options.queue()) ? YES : NO);
}

if (attrsDictionary.count > 0) {
NSAttributedString *announcementWithAttrs = [[NSAttributedString alloc] initWithString:announcement
attributes:attrsDictionary];
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcementWithAttrs);
} else {
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcement);
}
Expand Down
42 changes: 16 additions & 26 deletions packages/react-native/React/CoreModules/RCTActionSheetManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,15 @@ - (void)presentViewController:(UIViewController *)alertController
}

alertController.view.tintColor = tintColor;
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
NSString *userInterfaceStyle = [RCTConvert NSString:options.userInterfaceStyle()];

if (userInterfaceStyle == nil || [userInterfaceStyle isEqualToString:@""]) {
alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
} else if ([userInterfaceStyle isEqualToString:@"dark"]) {
alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
} else if ([userInterfaceStyle isEqualToString:@"light"]) {
alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
NSString *userInterfaceStyle = [RCTConvert NSString:options.userInterfaceStyle()];

if (userInterfaceStyle == nil || [userInterfaceStyle isEqualToString:@""]) {
alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
} else if ([userInterfaceStyle isEqualToString:@"dark"]) {
alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
} else if ([userInterfaceStyle isEqualToString:@"light"]) {
alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
#endif

[_alertControllers addObject:alertController];
[self presentViewController:alertController onParentViewController:controller anchorViewTag:anchorViewTag];
Expand Down Expand Up @@ -274,20 +269,15 @@ - (void)presentViewController:(UIViewController *)alertController
NSNumber *anchorViewTag = [RCTConvert NSNumber:options.anchor() ? @(*options.anchor()) : nil];
shareController.view.tintColor = [RCTConvert UIColor:options.tintColor() ? @(*options.tintColor()) : nil];

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
NSString *userInterfaceStyle = [RCTConvert NSString:options.userInterfaceStyle()];

if (userInterfaceStyle == nil || [userInterfaceStyle isEqualToString:@""]) {
shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
} else if ([userInterfaceStyle isEqualToString:@"dark"]) {
shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
} else if ([userInterfaceStyle isEqualToString:@"light"]) {
shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
NSString *userInterfaceStyle = [RCTConvert NSString:options.userInterfaceStyle()];

if (userInterfaceStyle == nil || [userInterfaceStyle isEqualToString:@""]) {
shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
} else if ([userInterfaceStyle isEqualToString:@"dark"]) {
shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
} else if ([userInterfaceStyle isEqualToString:@"light"]) {
shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
#endif

[self presentViewController:shareController onParentViewController:controller anchorViewTag:anchorViewTag];
}
Expand Down
20 changes: 9 additions & 11 deletions packages/react-native/React/CoreModules/RCTAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ - (UIWindow *)alertWindow

- (void)show:(BOOL)animated completion:(void (^)(void))completion
{
if (@available(iOS 13.0, *)) {
UIUserInterfaceStyle style =
RCTSharedApplication().delegate.window.overrideUserInterfaceStyle ?: UIUserInterfaceStyleUnspecified;
self.overrideUserInterfaceStyle = style;
}
UIUserInterfaceStyle style =
RCTSharedApplication().delegate.window.overrideUserInterfaceStyle ?: UIUserInterfaceStyleUnspecified;
self.overrideUserInterfaceStyle = style;

[self.alertWindow makeKeyAndVisible];
[self.alertWindow.rootViewController presentViewController:self animated:animated completion:completion];
}
Expand All @@ -65,14 +64,13 @@ - (void)hide

- (UIWindow *)getUIWindowFromScene
{
if (@available(iOS 13.0, *)) {
for (UIScene *scene in RCTSharedApplication().connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive &&
[scene isKindOfClass:[UIWindowScene class]]) {
return [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
}
for (UIScene *scene in RCTSharedApplication().connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive &&
[scene isKindOfClass:[UIWindowScene class]]) {
return [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
}
}

return nil;
}

Expand Down
Loading

0 comments on commit 610b14e

Please sign in to comment.