构建和调试Cordova插件的工作流程是什么?

时间:2022-01-08 15:18:04

I'm trying to build Cordova plugin that will expose native API to Cordova JS. The plugin will not be published to the public registry.

我正在尝试构建Cordova插件,将原生API暴露给Cordova JS。该插件不会发布到公共注册中心。

I'll like to understand what are the tools and flow to use to develop that? The cordova tool has only the ability to add/remove/ls plugin, how should I start a new plugin?

我想了解用于开发它的工具和流程是什么? cordova工具只能添加/删除/ ls插件,我应该如何启动新的插件?

I've try to use don/cordova-plugin-hello but when I try to modify the native implementation of ios and rebuild the project the result XCode project implementation is not updating.

我尝试使用don / cordova-plugin-hello,但是当我尝试修改ios的本机实现并重建项目时,结果XCode项目实现没有更新。

1 个解决方案

#1


I use xcode for iOS plugins and eclipse for android plugins

我使用xcode for iOS插件和eclipse for android插件

These are the steps I follow:

这些是我遵循的步骤:

  1. I create a new cordova project using the cordova CLI.
  2. 我使用cordova CLI创建了一个新的cordova项目。

  3. I open the project from eclipse/xcode
  4. 我从eclipse / xcode打开项目

  5. I create the native files for the plugin (.m/.h for ios, .java for android)
  6. 我为插件创建了本机文件(.m / .h用于ios,.java用于android)

  7. I create the common .js on the www folder and link it in the index.html
  8. 我在www文件夹上创建了常见的.js并将其链接到index.html

  9. Finally, I add this to the config.xml

    最后,我将其添加到config.xml中

    <feature name="PluginName"> <param name="ios-package" value="iOSPluginClassName" /> <param name="android-package" value="androidPluginClassNameIncludingPackage" /> </feature>

#1


I use xcode for iOS plugins and eclipse for android plugins

我使用xcode for iOS插件和eclipse for android插件

These are the steps I follow:

这些是我遵循的步骤:

  1. I create a new cordova project using the cordova CLI.
  2. 我使用cordova CLI创建了一个新的cordova项目。

  3. I open the project from eclipse/xcode
  4. 我从eclipse / xcode打开项目

  5. I create the native files for the plugin (.m/.h for ios, .java for android)
  6. 我为插件创建了本机文件(.m / .h用于ios,.java用于android)

  7. I create the common .js on the www folder and link it in the index.html
  8. 我在www文件夹上创建了常见的.js并将其链接到index.html

  9. Finally, I add this to the config.xml

    最后,我将其添加到config.xml中

    <feature name="PluginName"> <param name="ios-package" value="iOSPluginClassName" /> <param name="android-package" value="androidPluginClassNameIncludingPackage" /> </feature>