Embedding Cordova into Native iOS Project

Introductions:

It is a hybrid app that base on native project use cordova webview, not create project by cordova-cli. You could know more informations about iOS WebViews.
Assuming you already have a experience in Cordova and iOS Native when you are reading this article.

How can I embed Cordova in Native Project ?

First Step:

We will install the independent Cordova to Native Project by the Pod.

pod 'Cordova', '~> 4.3.0'
Second Step:

We should to obtain www folder,config.xml file and Native's Plugin from the pure project by Cordova-cli. It is necessary for configuring your native project with cordova plugin.

  1. You use the command-line to create a pure cordova file, then put your HTML distributed pack into myApp/www path.
    (If you use cordova-hot-code-push-plugin, and then use cordova-hcp build to create two files that "chcp.json" and "chcp.manifest" )
cordova create myApp org.apache.cordova.myApp myApp
  1. Then, using the first command line to create a iOS project, and the second add hot update plugins to iOS project.
cordova platform add ios
cordova plugin add cordova-hot-code-push-plugin
  1. We need manual copy these files to your native project.
    myApp/platforms/ios/www folder,
    myApp/platforms/ios/CordovaProject/config.xml file,
    myApp/platforms/ios/CordovaProject/Plugins/ all files
    Finally, We will get the file struct in native project such as the below figure.
    Don't forgot add these code to config.xml in order to config hot-code plugin.

   

![Upload [email protected] failed. Please try again.]

你可能感兴趣的:(Embedding Cordova into Native iOS Project)