kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.62k stars 67 forks source link

Xcode 15.4 iOS version 13 or higher #459

Closed imamrobani closed 4 months ago

imamrobani commented 4 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-keyboard-controller@1.12.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-keyboard-controller/ios/delegates/KCTextInputCompositeDelegate.swift b/node_modules/react-native-keyboard-controller/ios/delegates/KCTextInputCompositeDelegate.swift
index 3c4a609..d9405fc 100644
--- a/node_modules/react-native-keyboard-controller/ios/delegates/KCTextInputCompositeDelegate.swift
+++ b/node_modules/react-native-keyboard-controller/ios/delegates/KCTextInputCompositeDelegate.swift
@@ -93,7 +93,11 @@ class KCTextInputCompositeDelegate: NSObject, UITextViewDelegate, UITextFieldDel
   // MARK: UITextFieldDelegate

   func textFieldDidChangeSelection(_ textField: UITextField) {
-    textFieldDelegate?.textFieldDidChangeSelection?(textField)
+      if #available(iOS 13.0, *) {
+          textFieldDelegate?.textFieldDidChangeSelection?(textField)
+      } else {
+          // Fallback on earlier versions
+      }
     updateSelectionPosition(textInput: textField)
   }

This issue body was partially generated by patch-package.

kirillzyusko commented 4 months ago

Hey @imamrobani πŸ‘‹

Thank you for the report. May I ask you which RN version you are suing and which deployment target is set in XCode and which platform :ios is defined in Podfile?

kirillzyusko commented 4 months ago

@imamrobani and may I ask you to check if https://github.com/kirillzyusko/react-native-keyboard-controller/pull/460 fixes the problem?

Basically entire handler is available only for iOS 13+, so it makes sense just mark entire method with @avaialble annotation πŸ‘€

imamrobani commented 4 months ago

Hey @imamrobani πŸ‘‹

Thank you for the report. May I ask you which RN version you are suing and which deployment target is set in XCode and which platform :ios is defined in Podfile?

"react-native": "0.72.14", I already define 13.0 and try 13.5 but still not working

kirillzyusko commented 4 months ago

@imamrobani okay, thank you πŸ™

Does the code from my PR fixes compilation errors for you?

kirillzyusko commented 4 months ago

I generated a project with RM 0.72.14 and confirm the error is present.

With my PR the issue is gone - I tested on iOS 17.5 and handler gets fired (so it works as expected for newer iOS versions). I'm going to merge my PR - the issue will be automatically closed.

Thank you for the report and proposed solution ❀️

imamrobani commented 4 months ago

@imamrobani okay, thank you πŸ™

Does the code from my PR fixes compilation errors for you?

yes, thank you for helping