Skip to content

Running Your Application

In this article, we will cover how to compile and run your app on a real device.

By the end of this article, you will have done the following,

Install Dependencies

Steps

  1. To install the project dependencies, while in your project directory run npm install.
cd hamv_mobile
npm install

Tip: You can now preview the app in a browser using ionic serve.

ionic serve

Note, this runs in debug mode with error handling, but most logs can be ignored at this time. Your browser should open automatically once the application is ready. If not, in your browser open http://localhost:8100/

Build the Platforms

  1. Before adding a platform, you must have an Ionic account. To sign up for an Ionic account, run ionic signup and follow the steps on screen.
ionic signup

  1. Now you can create an Android/iOS project using ionic cordova platform add android or ionic cordova platform add ios.

  2. Android (Please run the following one by one)

ionic cordova platform add android
ionic cordova plugin remove wifiwizard2
ionic cordova plugin add https://github.com/VijayVaveHealth/wifiwizard2#master
  • iOS
ionic cordova platform add ios

Note: The first platform installation may take awhile to set up. (Estimated time: 15-20 minutes)

Congratulations! Your Ionic project is now ready to run on your phone.

Run the App on a Phone

Run on Android

Steps

  1. Install Android Studio. https://developer.android.com/studio/index.html
  2. Modify your bash file (Optional).

  3. For Linux: Modify your .bashrc file and add below content.

  4. For Mac: Modify your .bash_profile file and add below content.
export PATH=${PATH}:\~/Library/Android/sdk/tools:\~/Library/Android/sdk/platform-tools:\~/Library/Android/sdk/tools/bin
  1. Install the Android SDK (See Android Cordova)

To install, open the Android SDK Manager (run android or sdkmanager from your terminal) and make sure the following are installed:

  • Android Platform SDK for your targeted version of Android
  • Android SDK build-tools version 19.1.0 or higher
  • Android Support Repository (found under "Extras")

  • Enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --prod --device from your terminal.

ionic cordova run android --prod --device

To only build your app, run ionic cordova build android --prod

ionic cordova build android --prod

Run on iOS

Steps

1. Download Xcode from App Store and update to latest version. **Note**: This software installation can take awhile to set up.

2. Agree to the development license.
sudo xcodebuild -license accept
3. Install an iOS simulator running `npm i -g ios-deploy ios-sim`.
npm i -g ios-deploy ios-sim
4. Set up a developer certificate for your iOS app.

    \(1\) This requires free or paid Apple developer account. You can sign up here, [https://appleid.apple.com/](https://appleid.apple.com/)

    \(2\) Open ".xcworkspace" in Xcode. The file should be under`/platforms/ios/.xcworkspace`

    \(3\) Set a developer certificate for your app, as pictured below. Select your project in the left side menu, make sure you're in "General", then finally select your developer certificate under "Team", in the "Signing" section.

    \(4\) You can now close Xcode.

5. Build your app by running `ionic cordova build ios --prod -- --buildFlag="-UseModernBuildSystem=0"` from your terminal.
ionic cordova build ios --prod -- --buildFlag="-UseModernBuildSystem=0" 
6. Reopen your ".xcworkspace" in Xcode, then connect your phone via USB and select it as the run target, as pictured below.

7. You can now run your app on your phone by clicking the **play** button. Make sure your device remains USB connected and unlocked.

Have more questions? Submit a request