crosswalk-project / crosswalk-ios

Crosswalk Project for iOS
https://crosswalk-project.org/
BSD 3-Clause "New" or "Revised" License
117 stars 77 forks source link

Cordova Plugin Support instructions incomplete #16

Closed kicktheken closed 9 years ago

kicktheken commented 9 years ago

I've fixed some of the instructions for setting up cordova plugin here:

https://github.com/crosswalk-project/crosswalk-ios/wiki/Cordova-Plugin-Support

However, I still am not able to get the full Cordova plugin setup working. I've read through the code, and it seems that XWalkCordovaExtension.js injects the code from plugins/org.apache.cordova.device/www/device.js as a script in the global scope. Since it is in the global scope, the variables such as require and module are undefined and thus will throw an error on loading the plugin. That code is meant to be enclosed as such via cordova-cli builder:

cordova.define('cordova/device', function(require, exports, module) {
    // code goes here ...
});

However, I still cannot load the plugin. What is the issue?

jondong commented 9 years ago

@kicktheken Thanks for trying Crosswalk Project for iOS and your feedback, that is truly appreciated! I did miss some important steps in the wiki, I'll update it ASAP with more detailed and precise steps.

For the issue that I can see for now, the additional steps you may need to follow are:

  1. After cloned the crosswalk-ios project, you'll need to run git submodule update --init --recursive to retrieve the submodules which needed by Cordova project;
  2. Create a workspace and import XWalkView.xcodeproj, Cordova.xcodeproj and DeviceDemo.xcodeproj into it;
  3. After imported native and html5 codes from 'cordova-plugin-device', build target 'XWalkView' firstly and 'Cordova' secondly, then drag the generated 'XWalkView.framework' and 'Cordova.framework' into 'General' -> 'Embedded Binaries' in DeviceDemo's configure, then build 'DeviceDemo' target.

We have two Cordova plugin demos in Demos/Cordova/ directory, you may try them to test the Cordova plugin support.

Anything you need to know or issues you've found, feel free to let us know. Thanks very much for your help.

jondong commented 9 years ago

Hi @kicktheken , I've updated the Cordova Plugin Support Wiki with a more detailed process to create a demo, you may check it out. And feel free to let us know if there's any issue in it or any further suggestions. Thanks

kicktheken commented 9 years ago

Thanks! I'll try it out and let you know.