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
NPMCLI 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 CLIto create an app calledmy-appusin theblanktemplate usingCordovaas the Native Runtime and to use theAngularframework. -
There are a number of pre-built app templates that you can use with
Ionic, but here I am using theblanktemplate as I can build up the app how I like. -
You will be prompted to confirm that you want to use
Cordovainstead ofCapacitor- enteryto continue.Capacitoris theIonicdeveloped framework for hosting aWebviewbased app on a mobile device. The chief difference is thatCordovauses the command line to build native projects as a build asset whereasCapacitortreats them as a source asset and expects you to use native tooling, e.g.XcodeandAndroid Studio -
You will also be prompted to create an
Ionicaccount. There is absolutely no need to do so!
-
-
You can now
cdinto 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.