Saturday, July 5, 2014

Mobile Development with Cordova (Phonegap): Chapter 1

Chapter 1: Buying a Mac, buying an Android, then Getting Your Certificates Ready

Apps are digitally signed in order to verify that they come from the stated author. The paradigm of digital signatures is different between Android and iOS.

On iOS,  you must have an Apple developer account. An app is signed with your certificate, and Apple has your identity and credit card on file, so one could trace responsibility and ownership for an app back to the owner. And since the owner signed the app, they can hypothetically be held responsible for the app's content and behavior.

Android apps can be signed with any certificate, including self-generated self-signed certificates. These certificates can be generated at will. The signature of an app is used to verify that this app really does come from the same publisher. For instance, someone can create a Google Play developer account named "Green Info" and an app named ParkInfo Mobile and hope to fool users into thinking it's GreenInfo Network's ParkInfo Mobile app -- but if they try to upgrade to this fake app, the apps will have the same name but different signatures and the OS will refuse to install this fake upgrade.

As such, the very first step in developing mobile apps, is to generate the certificates which you will use to sign your Android apps, and signing up for an Apple Developer account for your iOS apps.

Buy a Mac

The development tools to build the app for iOS, are available only on OSX. While a Windows or Linux PC could build for Android, you still need a Mac to build for iOS, so you may as well embrace this and buy the Mac. Fortunately it only needs to run Mountain Lion or later, and there's no heavy code-crunching going on within Cordova, so a low-price used laptop off eBay should do you just fine.

Unless... If you intend to run the iOS emulators, you need all the CPU power and RAM you can afford. You also need an HD monitor; lower-resolution monitors will display the app strangely, since modern phones have better resolution than older monitors. For myself, I prefer to forgo the emulators and buy the iPad and iPhone and test on real hardware, since that costs less than a new Mac anyway.

Tip: To submit an app to the App Store you must have screenshots from an iPad, a 3.5" Retina iPhone, and a 4" Retina iPhone. This means that you must own all of these devices, and/or have beta testers who can take screen shots on these devices.

Android

For Android, the process is fairly straightforward: you generate a certificate yourself, and be sure to sign your APK files with the same certificate every time. As such, each version of the APK is assured to have come from the same author.

There is no central authority for these certificates, as the goal is simply to prove that the app comes from the same author, and not necessarily to tie the certificate to your personal identity.

There is a separate article dedicated to generating these "keystore" files.


Apple & iOS

For iOS, the situation is much more complex. You need to sign up at the Apple Developer website and pay a fee of $99 per year. You then need to define a certificate and a "provisioning profile" A provisioning profile is a combination of your Certificate, a selection of Application IDs (in case your company generates different types of applications with different teams.), a selection of devices (e.g. "these specific 5 iPads and 2 iPhones", or else "for public release") and additional Apple services and features (whether it uses their payment system, etc).

There is a separate article on how to generate certificates, and how to update Provisioning Profiles. You'll do this particularly when someone else wants to test out an app, and you'll need to add them to the device list and then build a new Provisioning Profile. But, you can at least run  the app on your own cable-attached device without generating a Provisioning Profile.


Buy your test hardware (or set up emulators)

You can test on hardware and on emulators.

Android emulators (Android Virtual Devices, AVDs) are set up via the android management application, which we discuss later when setting up the SDK. You'll want to create one with an old enough OS and low enough specs, that our testing will be applicable to trailing-edge phones.

For myself, I've had no good luck with the emulators. They may or may not, and if they do it's after several minutes, and they rarely have my app on them when they do start. Not wholly useful.

Android hardware comes in all sizes and prices. For $60 you can buy a crummy Craig tablet at Rite Aid or CVS pharmacies, and Nexus tablets showed up on Groupon for $110 a few weeks ago. I prefer to test on hardware, rather than deal with the buggy time-consuming emulators.

iOS emulators are much nicer. These are all built into Xcode: after you load your project, look in the upper-left to choose which device you want to use. If you have a hardware device attached (an iPad, an iPhone) you can select it from the menu as well. As such, there is no separate step for running your app on hardware iOS or emulated iOS.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.