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,
- To install the project dependencies, while in your project directory run
cd hamv_mobile npm install
Tip: You can now preview the app in a browser using
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¶
Before adding a platform, you must have an Ionic account. To sign up for an Ionic account, run
ionic signupand follow the steps on screen.
Now you can create an Android/iOS project using
ionic cordova platform add androidor
ionic cordova platform add ios.
Then add these lines:
- Android (Please run the following one by one)
ionic cordova platform add android
sed -i 's/defaultBuildToolsVersion="29.0.2"/defaultBuildToolsVersion="30.0.2"/g' platforms/android/build.gradle sed -i 's/defaultTargetSdkVersion=29/defaultTargetSdkVersion=30/g' platforms/android/build.gradle sed -i 's/defaultCompileSdkVersion=29/defaultCompileSdkVersion=30/g' platforms/android/build.gradle sed -i 's/target=android-29/target=android-30/g' platforms/android/project.properties sed -i 's/target=android-29/target=android-30/g' platforms/android/CordovaLib/project.properties
Finally, run “ionic cordova build android --prod --release”.
ionic cordova platform add ios
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¶
Install Android Studio. https://developer.android.com/studio/index.html
Modify your bash file (Optional).
- For Linux: Modify your .bashrc file and add below content.
- For Mac: Modify your .bash_profile file and add below content.
Install the Android SDK (See Android Cordova)
To install, open the Android SDK Manager (run
sdkmanagerfrom 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 --devicefrom 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¶
Download Xcode from App Store and update to latest version.
This software installation can take awhile to set up.
Agree to the development license.
sudo xcodebuild -license accept
Install an iOS simulator running
npm i -g ios-deploy ios-sim.
npm i -g ios-deploy ios-sim
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/
(2) Open ".xcworkspace" in Xcode. The file should be under
(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.
Build your app by running
ionic cordova build ios --prod -- --buildFlag="-UseModernBuildSystem=0"from your terminal.
ionic cordova build ios --prod -- --buildFlag="-UseModernBuildSystem=0"
Reopen your ".xcworkspace" in Xcode, then connect your phone via USB and select it as the run target, as pictured below.
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