NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
190 stars 109 forks source link

error TS2304: Cannot find name 'IQKeyboardManager' #406

Closed andrewm-mitchells closed 1 year ago

andrewm-mitchells commented 1 year ago

ns info

✔ Getting NativeScript components versions information...
✔ Component nativescript has 8.4.0 version and is up to date.
✔ Component @nativescript/core has 8.4.4 version and is up to date.
✔ Component @nativescript/ios has 8.4.0 version and is up to date.
✔ Component @nativescript/android has 8.4.0 version and is up to date.

Hello, I ran ns clean today and then on ns build ios --release I got an error related to IQKeyboardManager. Updated NS/NG and IQKeyboardManager plugin to latest but that didn't fix the issue.

This is what I have in references.d.ts:

/// <reference path="./node_modules/@nativescript/types/ios.d.ts" />
/// <reference path="./node_modules/@nativescript/types/android.d.ts" />

/// <reference path="./node_modules/@nativescript/types/index.d.ts" />
/// <reference path="./node_modules/@nativescript/iqkeyboardmanager/index.d.ts" />

I need this plugin to move from fields up when keyboard is visible on the screen. Below is my code to init KB manager.

const iqKeyboard = IQKeyboardManager.sharedManager();
iqKeyboard.keyboardDistanceFromTextField = 30;
EdJones commented 1 year ago

You ran ns plugin add nativescript-iqkeyboardmanager?

Has it worked before?

boris01 commented 1 year ago

@andrewm-mitchells try to add this to the references.d.ts /// <reference path="./node_modules/@nativescript/iqkeyboardmanager/typings/objc!IQKeyboardManager.d.ts" />

andrewm-mitchells commented 1 year ago

You ran ns plugin add nativescript-iqkeyboardmanager?

Has it worked before?

Added via npm i @nativescript/iqkeyboardmanager.

It worked fine until I ran ns clean today. Last time I ran it was maybe a week or two ago and it was fine at that time. I didn't update/install new plugin since then.

andrewm-mitchells commented 1 year ago

@andrewm-mitchells try to add this to the references.d.ts /// <reference path="./node_modules/@nativescript/iqkeyboardmanager/typings/objc!IQKeyboardManager.d.ts" />

That seems to be working, at least I was able to build. Will be testing to see if there are any issues related to it but big thank you for now!

NathanWalker commented 1 year ago

Thanks @andrewm-mitchells for providing the answer. The reason for this change is to adhere to the standard pattern of native typings usage throughout NativeScript at the moment. Previously this plugin exported global types from it's package which was incorrect since the plugin itself only provides a few classes. The IQKeyboardManager itself is a standard iOS Cocoapod so the plugin is published with the typings that you can include for usage if you'd like as you mentioned (adding to references.d.ts).