Understand the Frameworks
Last updated
Last updated
In short — If you create Native apps in Android, you code in Java. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. With Ionic and Cordova/Capacitor you can write a single piece of code for your app that can run on both iOS and Android (and windows!), that too with the simplicity of HTML, CSS, and JS.
It is important to note the contribution of Cordova/Capacitor in this. Ionic is only a UI wrapper made up of HTML, CSS and JS. So, by default, Ionic cannot run as an app in an iOS or Android device. Cordova/Capacitor is the build environment that containerizes (sort of) this Ionic web app and converts it into a device installable app, along with providing this app access to native APIs like Camera etc.
To install the latest ionic-cli, you need to run the below command
Capacitor is very similar to Cordova, but with some key differences in the app workflow
Cordova helps build Ionic web app into a device installable app. But there are some limitations of Cordova, which Capacitor tries to overcome with a new App workflow.
Capacitor is a cross-platform app runtime that makes it easy to build web apps that run natively on iOS, Android, Electron, and the web. Ionic people call these apps “Native Progressive Web Apps” and they represent the next evolution beyond Hybrid apps.
Here are the differences between Cordova and Capacitor
Capacitor considers each platform project a source asset instead of a build time asset. That means, Capacitor wants you to keep the platform source code in the repository, unlike Cordova which always assumes that you will generate the platform code on build time
Capacitor does not “run on device” or emulate through the command line. Instead, such operations occur through the platform-specific IDE. So you cannot run an Ionic-capacitor app using a command like ionic run ios
. You will have to run iOS apps using Xcode, and Android apps using Android studio
Because of the above, Capacitor does not use config.xml
or a similar custom configuration for platform settings. Instead, configuration changes are made by editing AndroidManifest.xml
for Android and Info.plist
for Xcode
Since platform code is not a source asset, you can directly change the native code using Xcode or Android Studio. This give more flexibility to developers. We will do some similar changes for Twitter login as well.
Cordova and Ionic Native plugins can be used in Capacitor environment. However, In this app, we do not use any of the Cordova plugins. All functionality have capacitor based plugins and capacitor is now as stable as cordova was. Now most of the apps and functionalities can be build using Capacitor.
Since Ionic 4, Ionic has become framework agnostic. Now you can create Ionic apps in Angular, React, Vue or even in plain JS. This gives Ionic great flexibility to be used by all kinds of developers.
React being the most popular framework today, it was inevitable that Ionic catches up to it, and now we have Ionic React - with the ease of coding from React, and ease of app development from Ionic.
Ionic Angular apps are supported by both Cordova and Capacitor build environments.
Same is not true for Ionic Vue apps — Ionic Vue apps are only supported by Capacitor build environment. Hence, if you want to build apps in Ionic Vue, you need to use Capacitor to build the app on device.