From e6dd22c628c3bf1b16bb319694a0dddcedb0dd7a Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Sat, 22 Jul 2023 11:57:46 -0700 Subject: [PATCH] Fix RCTBaseTextInputView for iOS 17 Summary: The change in D47554161 is breaking builds for iOS 17 as the `addEntriesFromDictionary` method returns void and the code tries to assign the returned value to another dictionary. ## Changelog: [iOS][Fixed] - Use `addEntriesFromDictionary` properly in RCTBaseTextInputView. Reviewed By: sammy-SC Differential Revision: D47696854 fbshipit-source-id: 49e01fdc63b3f0478762994d5cafdceb16830c74 --- .../Libraries/Text/TextInput/RCTBaseTextInputView.m | 7 ++++--- .../Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m index abd071bc8b9..233c76ed840 100644 --- a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -235,7 +235,8 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) static NSDictionary *contentTypeMap; dispatch_once(&onceToken, ^{ - NSDictionary *mutableContentTypeMap = @{ + NSMutableDictionary *mutableContentTypeMap = [NSMutableDictionary new]; + [mutableContentTypeMap addEntriesFromDictionary:@{ @"none" : @"", @"URL" : UITextContentTypeURL, @"addressCity" : UITextContentTypeAddressCity, @@ -264,11 +265,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) @"password" : UITextContentTypePassword, @"newPassword" : UITextContentTypeNewPassword, @"oneTimeCode" : UITextContentTypeOneTimeCode, - }; + }]; #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 /* __IPHONE_17_0 */ if (@available(iOS 17.0, *)) { - mutableContentTypeMap = [[mutableContentTypeMap mutableCopy] addEntriesFromDictionary:@{ + [mutableContentTypeMap addEntriesFromDictionary:@{ @"creditCardExpiration" : UITextContentTypeCreditCardExpiration, @"creditCardExpirationMonth" : UITextContentTypeCreditCardExpirationMonth, @"creditCardExpirationYear" : UITextContentTypeCreditCardExpirationYear, diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm index 6e3d662f15a..a7526fd562a 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm @@ -181,7 +181,8 @@ UITextContentType RCTUITextContentTypeFromString(std::string const &contentType) static NSDictionary *contentTypeMap; dispatch_once(&onceToken, ^{ - NSDictionary *mutableContentTypeMap = @{ + NSMutableDictionary *mutableContentTypeMap = [NSMutableDictionary new]; + [mutableContentTypeMap addEntriesFromDictionary:@{ @"" : @"", @"none" : @"", @"URL" : UITextContentTypeURL, @@ -211,11 +212,11 @@ UITextContentType RCTUITextContentTypeFromString(std::string const &contentType) @"password" : UITextContentTypePassword, @"newPassword" : UITextContentTypeNewPassword, @"oneTimeCode" : UITextContentTypeOneTimeCode, - }; + }]; #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 /* __IPHONE_17_0 */ if (@available(iOS 17.0, *)) { - mutableContentTypeMap = [[mutableContentTypeMap mutableCopy] addEntriesFromDictionary:@{ + [mutableContentTypeMap addEntriesFromDictionary:@{ @"creditCardExpiration" : UITextContentTypeCreditCardExpiration, @"creditCardExpirationMonth" : UITextContentTypeCreditCardExpirationMonth, @"creditCardExpirationYear" : UITextContentTypeCreditCardExpirationYear,