tree: 47c7b3955bb5701be9178c0b4989d3b99c7f6aca [path history] [tgz]
  1. helper_files/
  2. createmobilespec.cmd
  3. createmobilespec.js
  4. createmobilespec.sh
  5. package.json
  6. README.md
createmobilespec/README.md

Creating the mobile-spec app

createmobilespec.js is a script for creating a test app that has:

  • local cordova-mobile-spec
  • a cordova.js file that is freshly built from the local cordova-js folder
  • the platform (e.g. Android) from the local platform folder (e.g. cordova-android)
  • all the plugins from the local plugin folders (e.g. cordova-plugin-device)
  • it was built using the local cordova-cli and cordova-plugman folders

In other words, it is a great way to test your local development efforts.

The script also has options for creating the test app using a globally-installed npm module, a way to use the platform's cordova.js file instead of building it from the local cordova-js git repo, and a way to use the platform-centered workflow instead of the CLI.

Requirements and Preparation

  1. Your Cordova projects have to be checked out and set up in a very specific way: All checkouts have to be siblings (= same parent folder) and the common Cordova libraries have to be npm-linked.

    The easiest and quickest way to achieve this is by using cordova-coho:

    # Create a new folder, e.g. `cordova` and `cd cordova` into it.
    git clone https://github.com/apache/cordova-coho.git
    cd cordova-coho & npm install & cd ..
    node cordova-coho/coho repo-clone -r mobile-spec -r tools -r plugins -r active-platforms
    node cordova-coho/coho npm-link
    

    After this you should have 30+ folders in your cordova folder.

  2. As cordova-mobile-spec has a special structure, you have to install dependencies in createmobilespec manually:

    cd cordova-mobile-spec/createmobilespec & npm install & cd ../..
    
  3. You are now ready to use createmobilespec.js with the commands below.

Usage

The createmobilespec.js script also needs to be invoked from the “main” folder you created before (cordova).

To show formal usage (online help):

node ./cordova-mobile-spec/createmobilespec/createmobilespec.js --help

The node prefix on all commands is only needed on Windows, may be removed on other systems. For example:

./cordova-mobile-spec/createmobilespec/createmobilespec.js --help

On Windows, prefix all commands with node:

node cordova-mobile-spec/createmobilespec/createmobilespec.js

Create the App

Caution: If the generated mobilespec project already exists, it is recommended to delete the project before proceeding.

To create the app for the Android platform, for example, run:

node ./cordova-mobile-spec/createmobilespec/createmobilespec.js --android

In case anything is going wrong and the existing output does not help, add the --debug parameter:

node ./cordova-mobile-spec/createmobilespec/createmobilespec.js --android --debug

Run the App

After the script successfully finished and created the app, you can run the app on a device or simulator, using the standard method for that platform(s). For example on Android:

cd mobilespec
./cordova run android

Potential Quirks and Issues

Some known quirks and issues: