In the last part of this series we looked at [how to make use of native API’s in an Ionic application using Cordova]. In this part – which will be the final part in this series – we will discuss how to build Ionic applications for both iOS and Android. I’ll also provide a “mini analysis” of Sencha Touch vs Ionic based on my experience so far. Although this is the end of this particular series, there will still be plenty more Ionic content to come in the future.
There are two ways to create app store ready builds of Cordova / PhoneGap applications. The normal way is to build the application locally using the [CLI tools] installed on your computer, the other is to use [Adobe’s PhoneGap Build cloud building service].
The benefit of building locally is that applications can be built without having to upload to a third party service and you have more fine tuned control over your application and plugins. However, you will need to install the native SDK’s of the platform you are building for. If you want to build iOS applications, you need to have a Mac to install the required SDK’s, so if you have a Windows computer you’re out of luck and will only be able to build for Android.
The benefit of using PhoneGap Build is that compilation is handled in the cloud, so you do not need to install the SDK’s of the target platform on your computer. PhoneGap Build is much easier to set up and provides a way for Windows users to build iOS applications, but you do not have as much control over the application.
Building an Ionic Application Locally with Cordova through the Command Line
This tutorial will give most of the focus to building with PhoneGap Build, but I’ll also quickly walk through how you can create a build locally too. Once your environment is set up correctly it should be as simple as running a few commands.
- Add each platform that you wish to build for by running the following commands:
ionic platform add ios```ionic platform add android``` * Then run the build commands:ionic build ios```ionic build android``` There's certainly a few more steps you'll need to undertake before getting it on the app stores, like signing and submitting your applications though. For a more in depth tutorial I'd recommend checking out the [Ionic Publishing Guide] or [this tutorial on coderwall.com]. ## Building an Ionic Application with PhoneGap Build As far as I can tell, Ionic does not support [automated PhoneGap Build building through the CLI like Sencha Touch does by default]. So the process for getting an app built through PhoneGap Build wasn't nearly as smooth as the rest of my Ionic experience. I was contacted by Max Lynch, one of the Co-Creators of Ionic, via Twitter and this topic came up:[Andrew McGivery] (go check out his blog) responded:
@joshuamorony great write up, love these. Let us know if we can do anything to really wow you framework/tooling-wise 🙂
BONUS CONTENT: Enter your email address below to grab a quick start guide for setting up this process in your future projects.Thanks! Now check your email.
NOTE: These are just the version numbers at the time of writing this post, don't worry if yours are different.* Now just change your directory in a command terminal to your current project, and run:npm install``` to install any dependencies that are missing from your project.