[Cordova] Plugin Development Architecture Problem Scenario
When developing Cordova plugin, debugging native code is a troubling thing, because Cordova's error message is not so complete. It often takes a lot of time and spirit to find out that just one letter is wrong, virtually reducing the efficiency of development.
Solution Solutions
To increase the efficiency of Cordova plugin development, developers can accelerate development by applying the following development architectures:
Will actually provide the functionality of native Code, using the IDE encapsulated as the native Library. In this step, using the IDE to encapsulate the native Library, you can use the IDE's compile, debug, and test functions to quickly handle native code errors.
Reference data:
Development architecture
The IDE encapsulates the native Library, joins the Cordova plugin project, and uses Cordova plugin syntax to encapsulate native Code to provide JavaScript usage. In this step, try to avoid the logic falls in the package native code of the plugin category, let him only the transfer function, so that can reduce the complexity of the program, and thus reduce the risk of write errors.
Reference data:
[Cordova] Introduction to plugin Development
[Cordova] Use Android Library in plugin
[Cordova] Using iOS Framework in plugin
Development architecture
Finally, the native Code, encapsulated as Cordova plugin, can be completed and delivered using JavaScript wrappers for a more user-friendly style for subsequent developers. In this step, because the default cordova.exec function is encapsulated, that is, to try to choose Cordova.exec as a pointcut, to provide a mock mock plugin to isolate the development of JavaScript and native code, Let the two sides of the development can be carried out separately, avoid each other's development progress. and JavaScript and native isolation of the development method, but also easier to follow-up maintenance work, to avoid exception errors spread, resulting in difficult to troubleshoot the problem of error.
Reference data:
Development architecture
[Cordova] Plugin Development Architecture