Embedding Cordova into Native iO
2017-08-22 本文已影响60人
南国青天
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.
- You use the command-line to create a pure cordova file, then put your HTML distributed pack into
myApp/www
path.
(If you usecordova-hot-code-push-plugin
, and then usecordova-hcp build
to create two files that "chcp.json" and "chcp.manifest" )
cordova create myApp org.apache.cordova.myApp myApp
- 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
- 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.
<chcp>
<config-file url="https://5027caf9.ngrok.com/chcp.json"/>
</chcp>
![Upload QQ20170822-143804@2x.png failed. Please try again.]