Earlier this morning the Apache Cordova team released a cool update to the CLI (Tools Release: March 02, 2015). One of the most interesting aspects of this update is a new feature - the ability to save (and naturally restore) platforms and plugins.
To use this new feature, you simply add --save when adding a platform or plugin. As an example:
Notice how it specifically mentions that it is being saved into config.xml. And here is an example of saving a plugin:
If you look at your config.xml, you can see this information is now added.
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<engine name="ios" version="3.8.0" />
<feature name="File">
<param name="id" value="org.apache.cordova.file" />
</feature>
</widget>
So when are these settings used? When cordova prepare
is executed. If all you do is cordova emulate
while working, then this will handle it as well.
What about existing projects? Unfortunately there is no way to look at your current project and save everything as is. (I filed a bug report for that.) You would need to remove each platform and project and then re-add them with the flag. That won't take more than a minute though and is worth the effort if you're working on a team.
Be sure to read the blog entry for a full list of updates, and OSX users doing iOS should pay special attention to the note to update ios-deploy. Doing so will finally get rid of the warnings you would receive in Terminal.
Another update is the ability to list devices and emulator images from the command line. (Covered in detail in this bug report.) I was a bit confused as to how to use this at the CLI so I figured I'd share some tips.
First, if you want to get a list of emulator images, you would do this:
cordova emulate --list
This will not fire up the emulator but just list the available emulator types for your installed plugins. I've only got iOS as a platform in this project, but here's an example of the output.
To use this, you can then pass it as a target value like so: cordova emulate --target iPad-2
. In theory, all of this should work if you had multiple devices attached to your machine as well, but as I'm too lazy to go get my physical iOS devices, I'll just trust that it works. ;)
As a final tip, if you want to keep up to date with Cordova, you may want to subscribe to their RSS feed and use IFTTT to send you an email. Their RSS feed may be found at http://cordova.apache.org/rss.xml and IFTTT makes it easy to get emails from an RSS feed. This is what I do since I tend to fall behind on the public dev list.