concept emulator in category ionic

This is an excerpt from Manning's book Ionic in Action: Hybrid Mobile Apps with Ionic and AngularJS.
Now that at least one platform has been added to your app project, you can use one of the platform’s emulators to preview your app. If you haven’t already set up an emulator, you’ll need to do that first. Emulators are great for testing in a more real-world environment, but are slower to use during development. Launching and previewing in an emulator takes some processing time to set up and begin, especially the first time. If you’re on a Mac and emulating on iOS, you’ll also need to install ios-sim:
$ npm install -g ios-simNow you can run the app in an emulator using the emulate command:
$ ionic emulate ios $ ionic emulate androidThe emulator should open after running a number of tasks. You’ll see a lot of output in the command line as it builds and generates the necessary files, but as long as it ends with a success message, the emulator will launch and load your app.
When emulating Android, you can use –-target=NAME to run the app in a specific device you created; otherwise, the default emulator is used. iOS lets you change the hardware once the emulator has opened from the Hardware top menu.
If you already have the emulator up and running, you can run the emulate command again without closing the emulator. This is faster than exiting the emulator and relaunching it every time you change files, because the emulator doesn’t have to reboot itself each time.
We discussed in chapter 2 that emulators don’t provide the same experience as a real device. When it comes to working with Cordova plugins, it’s especially important to test your apps on a real device, but you can usually test them on an emulator as well.
Most plugins will work just fine with an emulator. Depending on the feature, the emulator might also allow you to simulate or modify the expected values. For example, you can modify the geographic coordinates for the emulator to simulate different locations without actually going there.
Some features aren’t available in the emulator, or may behave slightly differently. Because emulators are only virtual devices, some of the physical device abilities aren’t easily reproduced virtually. For example, on iOS there’s no way to use the camera plugin in the emulator.
Some plugins won’t work in an emulator due to missing features. If a plugin keeps failing, you should review the documentation to see if it works in an emulator. Error reporting about this problem can be poor, so it’s one of the things to check when troubleshooting. Using a connected device can help you avoid this problem, so I recommend using a real device when possible.
Emulators can be reset or rebuilt to be like new. This will make the emulator act like it’s brand new, and any existing modifications will be gone. This is helpful to do when you really want to be sure nothing is retained from before.