Your First Ionic Project

What is ionic?

Ionic is a cross-platform UI framework kit, which helps you to develop Android, iOS, Windows, Desktop Apps with single code base.
Before starting this tutorial, I assume that you have already had a proper setup on your machine. if not, please follow this tutorial.

How to create your ionic project?

To create a new ionic project you need to execute following commands on your terminal.

ionic start AppName blank

where,

  • ionic start is a command for starting a new project
  • AppName is your application name
  • blank is a template name.other template names: blank, sidemenu, tab

Once you have created a new project, we need to change our working directory for adding platform and plugins to do that,

cd AppName

How to run ionic project in the browser?

If you want to run your project on the browser, you can execute

ionic serve

Working with platforms

If you’re thinking about creating apps for android & ios, you just need to add platforms with your current project.

Note: You must need Mac for running ios

How to add platforms ionic ionic?

To add a new platform, we need to execute following commands (If you want to build/run your application for a device, you must add platform)

ionic cordova platform add
ionic cordova platform add android
ionic cordova platform add ios

If you want to add any specific version of the platform, you can use

ionic cordova platform add android@7.0.0

How to remove the platform in ionic?

In case, If you want to remove the platform you need to execute

ionic cordova platform rm
ionic cordova platform rm android
ionic cordova platform rm ios

How to view previously added platform?

If you want to see currently added platforms to your project, you need to execute

ionic cordova platforms

Working with plugins

Plugins are used for accessing device-specific features such as accessing the camera, geolocation, fingerprint authentication, and more.

How to add plugins?

If you want to add plugin, you can follow this

ionic cordova plugin add <plugin-name>

ionic cordova plugin add cordova-plugin-device
ionic cordova plugin add cordova-plugin-geolocation

If you want to add any specific version of the plugin you can follow this

ionic cordova plugin add cordova-plugin-geolocation@1.0.0

How to remove plugins?

If you want to remove any plugins, you can execute this

ionic cordova plugin rm

ionic cordova plugin rm cordova-plugin-device
ionic cordova plugin rm cordova-plugin-geolocation

How to view previously added plugins?

If you want to know all added plugins with your project, you can execute this cmd

ionic cordova plugins

How to build ionic apps?

If you want to generate executable or want to build, you need to follow this

ionic cordova build android
ionic cordova build ios

How to run ionic apps in device or simulator ?

If you want to run your current application on connected device/emulator, you can execute the following command

ionic cordova run android
ionic cordova run ios

Note: you must have the configuration for this.

Useful Links: