So far, you have been testing the web app portion of Ionic. Most of the time, you will need to actually run the app on a physical device or at least an emulator to see how the app behaves and whether all native features work.
Viewing the app using the Ionic CLI
Getting Ready
You will need to have the emulator installed. iOS emulator comes when you do npm install, -g ios-sim, and the Android emulator comes with Android Studio. To test the app on a physical device, you must connect the device to your computer via a USB connection.
How to do it...
- Add the specific platform (such as iOS) and build the app using the following command line:
$ ionic cordova platform add ios
$ ionic cordova build ios
- Note that you need to add the platforms to build the app. However, if you use the standard template from the Ionic CLI, it should already have the iOS platform included. To build and run for Android, you can replace iOS with Android.
- To emulate the app using the ios emulator, use the following command line:
$ ionic cordova emulate ios
- To run the app on the actual physical iPhone device, use the command line as shown:
$ ionic cordova run ios --device