Understand Visual Studio Tools for Apache Cordova

Recently I turned to Cordova for building a new version of my app, as I am a Visual Studio user, it’s great to get an official tools from Microsoft for Cordova.

Cordova is a tool for building web applications running in native shell. Due to the nature of web apps, and the effort make by Cordova team and its ecosystem, Cordova is also a great tool to build cross-platform apps.

Actually, Cordova also provide a way to develop web apps dedicated to a specific platform. Though that won’t be discussed in this post.

For building cross-platform web apps, refer to http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html

After creating a Cordova project, a “www” folder will be created with some initial files. The major project usually goes here. And there’s also a “platforms” folder that holds the project files for each platforms.

However, once a specific platform is added to your Cordova project, Cordova will leave most of the files as they are. This means that you may actually open a specific platform folder as a project in your IDE, edit and debug them.

Though these “most of the files” does not include cross-platform contents, e.g. contents in folder “www”.

The situation for plugins is quite the same, after the installation of plugins, Cordova will not touch the files that have already been generated, even if they’ve been changed by you.

This is what’s going on with Cordova CLI, however, not Visual Studio Tools for Apache Cordova.

Let’s put the directory structures of original Cordova and VS Tools together and we’ll be able to understand the differences.

Cordova CLI
- project
  - platforms
    - wp8
      - www
  - plugins
  - www
  - config.xml

VS Tools
- project
  - bld
    - Debug
      - platforms
        - wp8
          - www
      - plugins
      - www
      - config.xml
  - plugins
  - config.xml

VS Tools treat the entire project folder as “www” except for some special ones for Cordova. But after all it’s a tool box for Cordova, what’s their connection?

Basically a project defined by Visual Studio Tools for Cordova is not a real Cordova project, but a project that this tool will manage to convert to Cordova projects based on your configuration.

So what you see in bld\Debug\ (or Release) folder is the actual Cordova project.

I mentioned that Cordova won’t touch most of the files once they are generated. This good, but sometimes it will bring problems (e.g. install then uninstall plugins). However, the way Visual Studio Tools use brings also problems, and maybe even more…?

For example the installation of plugins does not support variables, and editing native projects is really painful.

But hoping they will solve these problems soon in the future when it goes to RTM.

Checkout Visual Studio Tools for Apache Cordova (CTP3).

Cordova 微信分享插件 (iOS, WP, Android)

先上 GitHub 链接 https://github.com/vilic/cordova-plugin-wechat

因为词焙需要, 然后现成的没有好用并且平台覆盖全面的, 于是就参考已有的自己写了个.

没有具体去看最低支持到 Cordova 多少, 但 3.x 应该问题不大. PhoneGap 估计也差不多.

支持三大系统, 除了安卓外, 基本不用额外配置, cordova plugin add com.wordsbaking.cordova.wechat –variable APP_ID=[你的AppID] 之后相关配置 (包括 URL Scheme) 都弄好了.

分享的内容只支持文本, 图片和链接. 以后空了再增加其他支持.

安卓需要额外修改一下 plugin.xml, 具体的参见 GitHub 上的说明.