From 1561cc9855174ddbd92aae6f7be87b87268aa716 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 3 Apr 2024 04:45:30 -0700 Subject: [PATCH] Wrap UIMenuAutoFill in compilation pragmas for iOS 17 checks (#43808) Summary: PR https://github.com/facebook/react-native/issues/43468 landed in main which uses UIMenuAutoFill that is available only in iOS 17. Despite having the `available` checks, these are only runtime checks. The symbol is not stripped on older versions of Xcode and therefore our jobs which uses older Xcode versions started failing. This change wraps the offending code in a compilation pragma that strips away the symbol when building with Xcode versions that does not know iOS 17. ## Changelog: [iOS][Fixed] - wrap UIMenuAutoFill in compilation checks for iOS 17 Pull Request resolved: https://github.com/facebook/react-native/pull/43808 Test Plan: CircleCI is green Reviewed By: cortinico Differential Revision: D55688255 Pulled By: cipolleschi fbshipit-source-id: d69874b60e73da1fbdfc61d594870a48f97c3797 --- .../Libraries/Text/TextInput/Multiline/RCTUITextView.mm | 7 +++++-- .../Libraries/Text/TextInput/Singleline/RCTUITextField.mm | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm index 4ccff230dd0..d5e2e220b1e 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm @@ -269,11 +269,14 @@ static UIColor *defaultPlaceholderColor(void) - (void)buildMenuWithBuilder:(id)builder { - if (_contextMenuHidden) { - if (@available(iOS 17.0, *)) { +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 + if (@available(iOS 17.0, *)) { + if (_contextMenuHidden) { [builder removeMenuForIdentifier:UIMenuAutoFill]; } } +#endif + [super buildMenuWithBuilder:builder]; } diff --git a/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm b/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm index 7ec5835df5c..03186710893 100644 --- a/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +++ b/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm @@ -144,11 +144,14 @@ - (void)buildMenuWithBuilder:(id)builder { - if (_contextMenuHidden) { - if (@available(iOS 17.0, *)) { +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 + if (@available(iOS 17.0, *)) { + if (_contextMenuHidden) { [builder removeMenuForIdentifier:UIMenuAutoFill]; } } +#endif + [super buildMenuWithBuilder:builder]; }