RBz
RBz

Reputation: 935

Understanding ionic and cordova wrappers

  1. For upgrading a plugin, it is suggested to do uninstall - add the cordova - then install that plugin. For Eg: The native Keyboard plugin

It have two steps:

How are these two related? How are their versions related? If i am installing a specific version of keyboard am i supposed to pick corresponding version for cordova as well? For example @ionic-native/keyboard is at 5.21.5 and cordova-plugin-ionic-keyboard is at 2.2.0.

  1. What does this line in my config.xml signifies? Does this have any impact to the ios version that i am using to build my app?

<engine name="ios" spec="^5.0.0" /> 

  1. Why do i even have these two (config and package) files anyway? I am seeing the cordova save adding the details to both the files!
  2. Where can i cross check if they have made changes to the project structure of plugins in their update. For example i was using the keyboard version 4.20.0 and when upgraded to 5.21.5 i had to change the import to point to the ngx folder. I wanted to find the first version from where they had this change and was not able to undenstand the documentation. How to keep these impacts minimum!?

Upvotes: 0

Views: 264

Answers (1)

xFGerald
xFGerald

Reputation: 35

For your first question:

ionic cordova plugin add command will download the cordova plugin with containe package.json, config.xml and save the plugin into your folder and set it for each plateform you use.

ionic-native as you said is simply a wrapper to the plugin you've just added. It install the package keyboard to your node-modules folder and sets the right way the plugin into the package.json. Also you can inject into the Angular provider wherever you need to use the plugin.


This line:

<engine name="ios" spec="^5.0.0" /> 

will be used by the builder to know which ios configuration it will use for the ios engine. Also hen you use an emulator to try making your app work localy. Every plugin may have an iOS version / Android Version / Windows Phone Version. Some features if you modify this config file will be not available on certain plateform. So for your third question, when you make a build or using "ionic serve" the package.json will be read and it will create a package-lock.json. These files are needed to build or localy run the app.

Finally, When you use these kind of plugins, i suggest you to create, class or services that are separated of your main code. In this case, if something change, you just have to modify one "File" and then all your app will continue working fine. In your main code just a

import {MyKeyboardClass} from "../shared-components/keyboard";

makes your code simple and easily alterable.

Hopes this help :)

Upvotes: 1

Related Questions