美文网首页
Embedding Cordova into Native iO

Embedding Cordova into Native iO

作者: 南国青天 | 来源:发表于2017-08-22 14:46 被阅读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.

    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.
    <chcp>
       <config-file url="https://5027caf9.ngrok.com/chcp.json"/>
    </chcp>
    

    ![Upload QQ20170822-143804@2x.png failed. Please try again.]

    相关文章

      网友评论

          本文标题:Embedding Cordova into Native iO

          本文链接:https://www.haomeiwen.com/subject/qhakdxtx.html