In this tutorial, we will take a look at how you can sign your app with the PhoneGap build service. We will create a signing key and use the PhoneGap build service to sign our app. The apps built by default by the PhoneGap build service are in debug mode, such apps are not allowed to be uploaded to any app store. To upload your app to any app store you will need to create the release version of your application. This can be done by signing your app.
This tutorial is a part of my Free PhoneGap Build Tutorial Course here.
What Does Signing An App Mean?
Before we dive any deep into signing our app let’s first talk about what signing an app means. Signing an app means exactly what signing a document means, it means that you are authorizing/approving the contents of the document and also that you are the owner of the document. Similarly, when you sign an app you are essentially proving the ownership of the app. So we will take the -debug app file and sign it, this will create a -release app file.
What Does A Digital Signature Mean?
As I mentioned the similarities between physical signature on a paper and a digital signature, but what does a digital signature actually mean. Well, basically you are encrypting your digital goods in this case our application. The way encryption works is that there are two keys. One key is called a private key and another one is called the public key. A special encryption algorithm is used to generate these keys and they are linked to one another in such a way that the value encrypted by private key can only be decrypted by the public key. You can read more about it by searching for public – private key encryption.
Creating A Signing Key For PhoneGap
For signing our application we will need to create a signing key. The signing key is at times is referred to as key certificate or signing certificate. One thing to note here is each platform has different ways of creating a signing key for their app, so we will need to create the signing key for Android, iOS and Windows by their respective methods. Fortunately for us, PhoneGap Build makes it easy for us to sign our app using the PhoneGap Build Dashboard. But we will need to create the three signing keys for the three platforms.
Note: You will need platform specific tools to create signing keys for different platforms. Until now we have been building apps using the PhoneGap Build service which has all the build tools for us, but for creating s signing key you will need to install some tools on your computer.
Creating A Signing key For Android And Signing Android App
Creating A Signing key
To create signing keys for Android you will need to have JDK. Installed and it’s path properly configured on your computer.
Open command prompt in the directory where you want to create the signing key. Then type the following command.
keytool -genkey -v -keystore [keystore_name].keystore -alias [alias_name] -keyalg RSA -keysize 2048 -validity 10000
[keystore_name] will be the name of the key file that will be generated so name it something meaningful e.g
myApp_key.keystore. Also, make sure you change the
[alias_name] to something which is relevant to your app. You can read in detail what each value means from the Android docs here.
After running the above command you will be prompted to set a password.
Make sure you write the password down and do not lose the password. If you loose your password you will have trouble in signing you app as well as updating your app in the future.
Enter all the details that you are prompted for by the keytool next one by one as shown below
The keytool will ask you for an
alias password , hit enter if you want it to be the same as you keystore password. If you choose a different password make sure to note it down as you will need it in the future.
After that, you will have a signing key created with a file extension of
.keystore inside the folder in which you have opened the command prompt .
Signing Android App
Now it’s time for us to submit the key to the PhoneGap Build service. So login to you PhoneGap Build dashboard and go to edit account>signing keys
Now that you are in the Signing keys section you will have the opportunity to upload keys for different platforms. You can upload the signing key by clicking the add a key button under each platform. A thing to note here is that the keys that you upload here will be uploaded under your account, meaning that the keys will be available across all apps and won’t be available for just one app.
Title can be anything you want, make sure you add a descriptive title as this title will be displayed when you choose a key. The
alias has to be the same which you entered whlie running the keytool command in step-2.
Once the signing key is uploaded it will be locked you will need to unlock it, so click on the locked padlock icon.
certificate password is the alias password that you entered in step-3 and the
keystore password is what you entered in step-2. After entering the passwords click on submit key.
This will unlock you signing key for 1 hour, you can now signing apps using this key for the next hour.
After unlocking the signing key we can now proceed to the actual signing of our app. Go to the apps section and select the app that you wish to sign. Under the build section, you can choose the signing key that you uploaded. After selecting a key PhoneGap build will automatically Rebuild your app for you. After the build process is complete you can download the app by clicking the apk button.
The file downloaded will be signed and be the release version of your app which can be uploaded to any app store.
Creating A Signing key For iOS And Signing iOS App
Creating A Signing key
You can read more about creating signing keys for iOSin the cordova platform guide here.
Signing iOS App
The process of signing iOS apps using PhoneGap build will be the same as that of Android as show above.
Creating A Signing key For Windows And Signing Windows App
Creating A Signing key
You can read more about creating signing keys for windows apps in the cordova platform guide here.
Signing Windows App
The process of signing Windows apps using PhoneGap build will be the same as that of Android as show above.
Before I conclude this post I want to give you guys a few important tips that I personally use.
- Make sure to save all the passwords mentioned in this tutorial in a safe place. Signing your app is not a regular thing and chances are that you will forget your password if you have to sign your app again to push an updated version of your app
- Don’t Lose your signing key. Save your signing key on multiple places and even in the cloud such as dropbox or google drive. If you lose your signing key you won’t be able to update your app
- Make sure to create a text file when you creating a signing key, in this text file save all the information that you entered in step-3 just in case you need it again.
Creating signing key for different platforms requires you to install the development tools and in some cases have a developer account and create a publisher ID. But PhoneGap build makes it easy for us to actually go through with the signing process. As you saw in the tutorial signing an app is a matter of choosing the signing key from the drop down menu and Phonegap build takes care of the signing process for you.
Watch Video Tutorial Here: