Create an Angular 12 App using Ionic 6 and Cordova 10
NB
You can develop the app and debug in a browser on any OS capable of running Node/NPM however you will need OS X to build, iOS resources and use the Xcode iOS Simulator or deploy to an iOS device locally for debugging.
-
Install globall
NPM
CLI toolsnpm install -g @angular/cli@12.1.4 npm install -g @ionic/cli@6.18.0 npm install -g cordova@10.0.0
-
Create the app
ionic start my-app blank --cordova --type=angular
-
This tells the
Ionic CLI
to create an app calledmy-app
usin theblank
template usingCordova
as the Native Runtime and to use theAngular
framework. -
There are a number of pre-built app templates that you can use with
Ionic
, but here I am using theblank
template as I can build up the app how I like. -
You will be prompted to confirm that you want to use
Cordova
instead ofCapacitor
- entery
to continue.Capacitor
is theIonic
developed framework for hosting aWebview
based app on a mobile device. The chief difference is thatCordova
uses the command line to build native projects as a build asset whereasCapacitor
treats them as a source asset and expects you to use native tooling, e.g.Xcode
andAndroid Studio
-
You will also be prompted to create an
Ionic
account. There is absolutely no need to do so!
-
-
You can now
cd
into the app directory and start serving your app.cd my-app ionic serve
- This starts a development server with Live Reload (typically on port `localhost:8100’ unless that port is already in use).
- When making Web Service calls remember that you may need to configure your allowed origins to handle this when debugging locally.
You can use the Ionic CLI to scaffold new Components, Modules etc. (ionic g ...
), stick with Angular CLI (angular g ...
) or use both.
At it’s heart Ionic
consists of a set of Components
that are optimised for display on Mobile devices and deal with things like camera cutouts etc. (Components documentation).
You’ll probably find that it’s easier to use the Ionic CLI for Ionic components.
The next step is to add a Platform such as iOS or Android so that you can compile for those devices. I will cover creating and deploying an iOS app in the next posts.