PhoneGap Desktop App

Step 1: Install PhoneGap

The PhoneGap Desktop application provides a drag and drop interface for creating PhoneGap applications. It's an alternative to using the PhoneGap CLI built for those who prefer a visual user interface over a command line interface approach.
NOTE: The getting started steps vary based on the initial PhoneGap tool you install here in step 1. For the rest of the steps be sure to choose either the Desktop or CLI tab at the top accordingly.
Select your operating system to continue:

Mac OS X Installation

  1. Download the latest Mac OS X Installer.
  2. Double-click the downloaded file to run the installer. You will initially be prompted with a license agreement to accept:
  3. Drag and drop the application into the Applications folder on your Mac as prompted:
  4. Next simply open the application and proceed to Step 2 where you will install the PhoneGap Developer App to your mobile device for previewing the apps you build.

Windows Installation

  1. Download the latest Windows Installer.
NOTE: If you're unable to run the Windows Installer for some reason, there's also a zip file available that can be used to install PhoneGap Desktop manually. Download the zip file for the latest releaseand follow the instructions in the README and INSTALL files within the downloaded zip.
  1. Double click the downloaded file to run the installer. You will be prompted with the PhoneGap Desktop Setup Wizard:
  2. Accept the license agreement:
  3. Select the desired destination for the application and click Next:
  4. Select the desired location for the shortcut and click Next:
  5. Click Install to begin the installation:
  6. Click Finish to close the Setup Wizard:
  7. Next simply open the application and proceed to next step below where you will install the PhoneGap Developer App to your mobile device for previewing the apps you build.

Step 2: Install Mobile App

The PhoneGap Developer App is a mobile app that runs on devices and allows you to preview and test the PhoneGap mobile apps you build across platforms without additional platform SDK setup. It automatically provides access to the PhoneGap core APIs providing instant access to the native device features without having to install any plugins or compile anything locally. It's meant to provide an easy way for developers to get started creating and testing their PhoneGap applications quickly with minimal setup.

Install PhoneGap Developer

  1. Locate the free PhoneGap Developer app from one of the following supported app marketplaces and install it to your mobile device:
  2. Once installed, tap the PhoneGap Developer app icon from your home screen to open it:
    PhoneGap Developer App, iOS
  3. Once installed, move on to the next step where you will create your first PhoneGap app using the tool you selected in step 1.
    NOTE: The platform SDKs mentioned above refer to the software development kits Apple, Google and Microsoft provide to build applications for their platforms (iOS, Android and Windows respectively). When you're ready to take your mobile application development further or decide you want to build for each platform locally yourself, you can find the specific instructions for each platform in the PhoneGap Platform Installation Guides.

Step 3: Create Your App

Now that you've installed PhoneGap Desktop and/or the PhoneGap CLI to your computer and the PhoneGap Developer App to your mobile devices, you're ready to create your first PhoneGap project. This project will be a PhoneGap mobile app with the ability to run on multiple devices and across operating systems in just a few simple steps.

Create a PhoneGap Project

  1. Click the plus sign and select Create new PhoneGap project as shown below:
  2. You will be prompted with the template list dialog as shown below, where you can choose to create an app based on a sample project.
Each template has a brief description below the name indicating what type of project will be created. To select a template, click on the radio button next to it. In the image below, the Hello World template is selected.
Templates Dialog
The first template option in the list is the default Hello World project. It's proven to be the quickest and easiest way to understand the basics of building a mobile PhoneGap app so let's start there.
  1. Ensure the radio button next to the Hello World template is selected.
  2. Click on the green Next button.
  3. You will be presented with a screen to enter information about your project. Choose the path on your local hard drive where you want to create the project, a designated name and an optional identifier. Once the information has been entered, click the green Create project button.
    Be aware that the ID field is also known as the package identifier for Android and the bundle identifier for iOS.
  4. You should now see a view like below, with your new project shown and marked with a left green border, a green play button next to it and a green bar at the bottom. You should also see a server address indicating it's running and the active project. Only one project will be active and running at any time.
    TIP: The server address shown for your project at the bottom in the green bar will be used in the next step so make note of it or keep it open.

Share:

PhoneGap Short Code


Installation

There are a few basic requirements you'll need prior to installing the PhoneGap CLI:
  • Node.js - a JavaScript runtime to build your JavaScript code
  • git - used in the background by the CLI to download assets. It comes pre-installed on some operating systems. You can check if it's already installed by typing git from the command line.

Install via npm

Run the following command to install the latest version of the PhoneGap CLI:
$ npm install -g phonegap

Installing a Specific Version

You can install a specific version of the PhoneGap CLI via npm by specifying the version number after the @symbol:
$ npm install -g phonegap@5.1.1
TIP: To get a listing of the PhoneGap CLI versions available, you can run $ npm info phonegap
If you get an EACCES error when running any of the commands here, try prefixing it with sudo, such as: $ sudo npm install -g phonegap

Create an App

Create a new application project at the provided path. You can optionally specify a name and package ID via the options parameters listed below, or configure it in the config.xml file after project creation.

Usage

phonegap create [options] <path> [id [name [config]]]
You can specify some options when creating your project, including a template to use as a base project or an existing project to copy from or symbolically link to on your hard drive. Use the template listcommand to view the templates currently available.

Options

--name, -n <name>         application name (default: "Hello World")
--id, -i <package>        package name (default: "com.phonegap.hello-world")
--template <name>         create app using an existing app template
--copy-from, -src <path>  create project using a copy of the www folder from an existing project
--link-to <path>          symlink/shortcut to the www folder of another project without copying

Config Parameter

The [config] parameter allows you to pass a JSON string with configuration parameters some plugins may specifically rely on. They are injected into the <path>/.cordova/config.json file.

Examples

$ phonegap create path/to/myApp
$ phonegap create path/to/myApp "com.example.app" "My App"
$ phonegap create path/to/myApp --id "com.example.app" --name "My App"
$ phonegap create path/to/myApp --template hello-world
$ phonegap create path/to/myApp --copy-from ../myOtherApp
$ phonegap create path/to/myApp -src ../myOtherApp
$ phonegap create path/to/myApp --id "com.example.app" --name "My App" --copy-from ~/myOtherApp
$ phonegap create path/to/myApp --link-to ../myOtherApp
Note: Check out the templates guide for more details on how to create applications based on templates.



Serve an App ( Run On Browser )

The serve command is used to start up a local web server to host the application for the PhoneGap Developer app (or any browser) to consume.

Usage

phonegap serve [options]

Options

Some options are available for specifically setting the port to use, to enable or disable auto reload, or to setup a local tunnel for public access as shown below.
--port, -p <n>       port for web server (default: 3000)
--autoreload         enable app refresh on file changes (default: true)
--no-autoreload      disable app refresh on file changes
--browser            enable desktop browser support (default: true)
--no-browser         disable desktop browser support
--localtunnel        enable a local tunnel for public access (default: false)

Alias

$ phonegap app

Examples

$ phonegap serve
$ phonegap serve --port 1337
$ phonegap serve --no-autoreload
$ phonegap serve --browser
$ phonegap serve --no-browser
$ phonegap serve --localtunnel
$ phonegap app

Update Version

Manually Update

To update your PhoneGap CLI to the latest version, run the following command:
$ npm install -g phonegap
NOTE: If you get an Error: EACCES when running any of the commands here, try prefixing it with sudo, such as: $ sudo npm install -g phonegap

Update Available Notification

The CLI will also display a notification when any command is used if an update is available:
$ phonegap -v
6.0.3

   ---------------------------------------
   |                                     |
   |   Update available 6.0.3 -> 6.0.4   |
   |   Run npm i -g phonegap to update   |
   |                                     |
   ---------------------------------------
NOTE: This notification will only be displayed once every 24 hours.
To disable the update notifier, you can do one of the following:
  1. Use the --no-update-notifer flag with any PhoneGap command.
    • For example, phonegap run ios --no-update-notifier
  2. Disable the update notifier by altering the configuration file.
    1. Open ~/.config/configstore/update-notifier-phonegap.json
    2. Set the property "optOut": true

Share:

Cordova short code


Installing the Cordova CLI
The Cordova command-line tool is distributed as an npm package.
To install the cordova command-line tool, follow these steps:
  1. Download and install Node.js. On installation you should be able to invoke node and npm on your command line.
  2. (Optional) Download and install a git client, if you don't already have one. Following installation, you should be able to invoke git on your command line. The CLI uses it to download assets when they are referenced using a url to a git repo.
  3. Install the cordova module using npm utility of Node.js. The cordova module will automatically be downloaded by the npm utility.
  • on OS X and Linux:
       $ sudo npm install -g cordova
    
    On OS X and Linux, prefixing the npm command with sudo may be necessary to install this development utility in otherwise restricted directories such as /usr/local/share. If you are using the optional nvm/nave tool or have write access to the install directory, you may be able to omit the sudo prefix. There are more tips available on using npm without sudo, if you desire to do that.
  • on Windows:
       C:\>npm install -g cordova
    
The -g flag above tells npm to install cordova globally. Otherwise it will be installed in the node_modules subdirectory of the current working directory.
Following installation, you should be able to run cordova on the command line with no arguments and it should print help text.

Create the App

Go to the directory where you maintain your source code, and create a cordova project:
$ cordova create hello com.example.hello HelloWorld
This creates the required directory structure for your cordova app. By default, the cordova create script generates a skeletal web-based application whose home page is the project's www/index.html file.

Add Platforms

All subsequent commands need to be run within the project's directory, or any subdirectories:
$ cd hello
Add the platforms that you want to target your app. We will add the 'ios' and 'android' platform and ensure they get saved to config.xml and package.json:
$ cordova platform add ios
$ cordova platform add android
To check your current set of platforms:
$ cordova platform ls
Running commands to add or remove platforms affects the contents of the project's platforms directory, where each specified platform appears as a subdirectory.
Note: When using the CLI to build your application, you should not edit any files in the /platforms/ directory. The files in this directory are routinely overwritten when preparing applications for building, or when plugins are re-installed.

Install pre-requisites for building

To build and run apps, you need to install SDKs for each platform you wish to target. Alternatively, if you are using browser for development you can use browser platform which does not require any platform SDKs.
To check if you satisfy requirements for building the platform:
$ cordova requirements
Requirements check results for android:
Java JDK: installed .
Android target: installed android-19,android-21,android-22,android-23,Google Inc.:Google APIs:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:23
Android SDK: installed
Gradle: installed
Apple OS X: not installed
Requirements check results for ios:
Error: Some of requirements check failed
Cordova tooling for iOS requires Apple OS X

Share:

ionic short code




Installing Ionic

Ionic apps are created and developed primarily through the Ionic command line utility (the “CLI”), and use Cordova to build/deploy as a native app. This means we need to install a few utilities to get developing.

Getting Node and NPM

Most of the tooling in the CLI is based on Node and is managed through npm. The quickest way to get Node and NPM installed on your machine is through the NodeJS installer. Be sure to install the LTS version of Node. Close any terminals/command prompts you may have open, run the installer, and launch a new terminal window. To verify you have everything installed correctly, you can run npm --version and node --version. If this errors, please resolve before moving on.

Ionic CLI and Cordova

With Node and NPM setup, let’s install the Ionic and Cordova CLI.
$ npm install -g ionic cordova
Note: The -g means this is a global install, so for Window’s you will need to open an Admin command prompt. For Mac/Linux, you’ll need to run the command with sudo.
Once that’s done, create your first Ionic app:
$ ionic start helloWorld blank
To run your app, cd into the directory that was created and then run the ionic serve command to test your app right in the browser!
$ cd helloWorld
$ ionic serve


Starting a New Ionic App

To start a new app, open your terminal/command prompt and run:
$ ionic start MyIonicProject tutorial

Viewing the app in a browser

Now, you can cd into the folder that was created. To get a quick preview of your app in the browser, use the serve command.
$ cd MyIonicProject/
$ ionic serve


























Share:

Popular Posts