0

I do not understand how Cordova (latest version 6.1) deals with plugins. I have the following project for my app:

myapp (only relevant folders and files shown)
+-config.xml
+-platforms
| +-ios
|   +-CordovaLib
|   +-MyApp
|     +-Plugins
|       +-com-myproj-myplugin
|         |-myplugin.h
|         |-myplugin.m
+-plugins
| +-com-myproj-myplugin
|   |-plugin.xml
|   +-src
|     +-ios
|       |-myplugin.h
|       |-myplugin.m
+-www

As you can see, this project has a plugin myplugin which resides in 2 directories:

  • The root plugins folder - Here file myapp\plugins\com-myproj-myplugin\src\ios\myplugin.m does not contain any code implementation (just signatures and empty content in functions).
  • The iOS application specific Plugins folder - Here file myapp\platforms\ios\MyApp\Plugins\com.myproj.myplugin\myplugin.m actually contains the implementation.

Where is the redundancy?

I thought that the model was as follows:

  1. I call cordova build ios.
  2. Cordova will copy resources from myapp\plugins\ into specific platform plugin folders in myapp\platforms\...\Plugins\

But turns out this is not the case. No copy is performed from the general plugins folder into platform specific Plugins folders.

The plugin Here is my plugin.xml for my plugin:

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.myproj.myplugin" version="0.1.0">
  <name>MyPlugin</name>
  <description>Just my plugin</description>
  <license>Me</license>
  <js-module src="www/myplugin.js" name="myplugin">
    <clobbers target="myplugin" />
  </js-module>

  <!-- ios -->
  <platform name="ios">
    <config-file target="config.xml" parent="/*">
      <feature name="MyPlugin">
        <param name="ios-package" value="MyPlugin"/>
        <param name="onload" value="true"/>
      </feature>
    </config-file>

    <header-file src="src/ios/myplugin.h" />
    <source-file src="src/ios/myplugin.m" />
  </platform>
</plugin>

My question How am I supposed to develop the plugin in order to avoid this redundancy? Should the code be placed only in platform specific Plugins folder? But how about plugin.xml which is placed in the generic plugins folder?

7
  • You want to create your own plugin? You have to create the plugin folder with the classes and a plugin.xml file. The plugin.xml file is the one that tells cordova what to copy. Commented Apr 13, 2016 at 14:00
  • @jcesarmobile: Yes, however why isn't Cordova copying those files into platform specific plugin folders?
    – Andry
    Commented Apr 14, 2016 at 6:51
  • Do you have the plugin.xml file? Commented Apr 14, 2016 at 6:55
  • Yes I have for that specific plugin and it is specific the header and the source file.
    – Andry
    Commented Apr 14, 2016 at 7:12
  • If you install the plugin from the CLI and you have the plugin.xml then the files should be copied to the right place Commented Apr 14, 2016 at 7:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.