Skip to content

fix bug | ^ 'keyboardLayoutGuide' is only available in iOS 15.0 or newer #1069

@vtwoptwo

Description

@vtwoptwo

Hi! 👋

Firstly, thanks for your work on this project! 🙂

  • When building an ios app with the package the build would stop due to this error: 'keyboardLayoutGuide' is only available in iOS 15.0 or newer, fixed it for my app with this solution.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-keyboard-controller/ios/observers/KeyboardTrackingView.swift b/node_modules/react-native-keyboard-controller/ios/observers/KeyboardTrackingView.swift
index 95ab759..39cf62e 100644
--- a/node_modules/react-native-keyboard-controller/ios/observers/KeyboardTrackingView.swift
+++ b/node_modules/react-native-keyboard-controller/ios/observers/KeyboardTrackingView.swift
@@ -66,16 +66,18 @@ final class KeyboardTrackingView: UIView {
 
     translatesAutoresizingMaskIntoConstraints = false
 
-    if #available(iOS 17.0, *) {
-      rootView.keyboardLayoutGuide.usesBottomSafeArea = false
+ if #available(iOS 15.0, *) {
+      if #available(iOS 17.0, *) {
+        rootView.keyboardLayoutGuide.usesBottomSafeArea = false
+      }
+
+      NSLayoutConstraint.activate([
+        leadingAnchor.constraint(equalTo: rootView.leadingAnchor, constant: 0),
+        trailingAnchor.constraint(equalTo: rootView.trailingAnchor, constant: 0),
+        bottomAnchor.constraint(equalTo: rootView.keyboardLayoutGuide.topAnchor, constant: 0),
+        heightAnchor.constraint(equalToConstant: 0),
+      ])
     }
-
-    NSLayoutConstraint.activate([
-      leadingAnchor.constraint(equalTo: rootView.leadingAnchor, constant: 0),
-      trailingAnchor.constraint(equalTo: rootView.trailingAnchor, constant: 0),
-      bottomAnchor.constraint(equalTo: rootView.keyboardLayoutGuide.topAnchor, constant: 0),
-      heightAnchor.constraint(equalToConstant: 0),
-    ])
   }
 
   @objc private func keyboardWillAppear(_ notification: Notification) {

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

Labels

build error ❌Anything that triggers build errors and prevent this library from being used🍎 iOSiOS specific

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions