Wednesday, July 15, 2015

Downloading and Playing around with Coredova

Based on the instructions given at the web site, it is better to install the coredova CLI from the npm rather than downloading this .zip version.  
Coredova CLI is used for creating and deploying Applications. 

Before Installing CLI tools, the native Platforms SDK needs to be installed. The cordova CLI is distributed in npm form readily available to install it. It is not necessary to compile it from source. 

The below are the main steps involved in installing the CLI

1. node.js installation. since the CLI installation is using the npm command, the node.js needs to be installed. This can be installed from the link given in the reference section. node.js is a pkg ed MAC application and once after installing below message was shown 

Node was installed at
   /usr/local/bin/node
npm was installed at
   /usr/local/bin/npm
Make sure that /usr/local/bin is in your $PATH.

After it was installed, the Terminal was able to successfully find it because npm was showing the options listed. 

The installation command for corrodva is simple and it is  sudo npm install -g cordova

it gave below few details upon running the above command. 
npm WARN engine cordova-js@4.0.0: wanted: {"node":"~0.10.x"} (current: {"node":"0.12.7","npm":"2.11.3"})
npm WARN engine npm@1.3.4: wanted: {"node":">=0.6","npm":"1"} (current: {"node":"0.12.7","npm":"2.11.3"})
npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.7","npm":"2.11.3"})
npm WARN installMany normalize-package-data was bundled with npm@1.3.4, but bundled package wasn't found in unpacked tree
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
cordova@5.1.1 /usr/local/lib/node_modules/cordova
├── underscore@1.7.0
├── q@1.0.1
├── nopt@3.0.1 (abbrev@1.0.7)
└── cordova-lib@5.1.1 (valid-identifier@0.0.1, osenv@0.1.0, properties-parser@0.2.3, bplist-parser@0.0.6, mime@1.2.11, unorm@1.3.3, semver@2.1.0, shelljs@0.3.0, dep-graph@1.1.0, rc@0.5.2, xcode@0.6.7, through2@0.6.3, npmconf@0.1.16, elementtree@0.1.6, cordova-app-hello-world@3.9.0, glob@4.0.6, d8@0.4.4, request@2.47.0, plist@1.1.0, cordova-registry-mapper@1.1.8, npm@1.3.4, init-package-json@1.7.0, tar@1.0.2, cordova-js@4.0.0)


after the npm is installed, in order to access the coredova using the sudo command as it get installed in to the restricted directory. 

Below is the command that can be executed to create a sample hello world project 

sudo  cordova create hello com.example.hello HelloWorld

the first argument hello specifies the directory to be generated for the project. the www subdirectory hosts the applications home page along with various resources under css, js and img folders. the config.xml contains the important meta data needed to generate and distribute the application. 

To add Platforms to the project, below command needs to run (this needs to be run under the project folder that is created) 

$ sudo cordova platform add ios 
npm http GET https://registry.npmjs.org/cordova-ios
npm http 200 https://registry.npmjs.org/cordova-ios
npm http GET https://registry.npmjs.org/cordova-ios
npm http 200 https://registry.npmjs.org/cordova-ios
npm http GET https://registry.npmjs.org/cordova-ios/-/cordova-ios-3.8.0.tgz
npm http 200 https://registry.npmjs.org/cordova-ios/-/cordova-ios-3.8.0.tgz
Adding ios project...
iOS project created with cordova-ios@3.8.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist@1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 200 https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.0.0.tgz
npm http 200 https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.0.0.tgz
Installing "cordova-plugin-whitelist" for ios

to build the application, just need to do run this  sudo cordova build 

This creates the app file. 

References:

No comments:

Post a Comment