Search code examples
ioscordovacordova-plugins

How to use native ios code with cordova?


I have native ios code project , I can run it fine without any problem , my aim is to use some classes in that project with cordova project .

I have create cordova project and copied the classes from native ios code to my cordova projoct but I get errors , also I have copying cordova classes .. lib .. etc to the native ios project , also I get errors , how I can run ios native project with cordova ?


Solution

  • You can create a cordova plugin that use native classes, basically is a JavaScript Interface that call native code methods.

    If you have more that one class, all your classes can be included in plugin.xml under <platform name="ios"> tag. In this way you can use all functions that you want.

    The only way to create a plugin is following the official guide. Read this documents:

    Cordova plugin development guide: https://cordova.apache.org/docs/en/5.4.0/guide/hybrid/plugins/index.html

    iOS plugin development guide: https://cordova.apache.org/docs/en/5.4.0/guide/platforms/ios/plugin.html