The Challenge of iOS Development on Windows

We are working on a hybrid mobile application. The demand for hybrid mobile applications is increasing as it is a great alternative to developing mobile applications for their native platforms. Creating mobile applications for all native platforms separately is time-consuming.

There are a lot of platforms available for hybrid mobile applications, but we chose Ionic for this. Ionic is a beautiful, free, and open-source mobile SDK for developing native and progressive web apps with ease.

When we develop a mobile application, it is very easy to create an APK for testing and use it on any Android device. However, it becomes very complicated when it comes to creating an IPA for iOS devices. To create an IPA for your application on iPhones or iPads, we typically require Xcode or a MacBook. But what if you don’t have a MacBook or Xcode available?

Prerequisites: OpenSSL

We are providing easy steps to create an IPA for iOS devices using PhoneGap Build and OpenSSL.

The first thing required is a developer account at developers.apple.com so that we can create iOS certificates like .mobileprovision, .pem, and .p12 certificates.

To create certificates, you need OpenSSL installed on your Ubuntu or Windows system.

Step 1: Generating Certificates

Generating the Request

If you are on Windows, navigate to your OpenSSL directory:

cd C:\OpenSSL-Win32\bin

If you are a Linux user, open the terminal with sudo su and start from the commands below.

1. Generate the RSA key:

openssl genrsa -out ios_distribution.key 2048

2. Generate the Certificate Signing Request (CSR):

openssl req -new -key ios_distribution.key -out CertificateSigningRequest.certSigningRequest -subj "/emailAddress=YOUREMAIL, CN=YOUR NAME, C=COUNTRYCODE"

Apple Developer Portal

3. Go to the Apple Developer Portal and sign in. Go to “Certificates” under iOS.

4. Under the Certificates menu on the left, click “All”, and then the “+” button (Add).

5. Pick either a Development “iOS App Development” or a Production “App Store and Ad Hoc” certificate. Note: You will need to go through the process twice to have both a development and a production version of the app.

6. Download the “Worldwide Developer Relations Certificate Authority” (AppleWWDRCA.cer) file from the same page.

7. Click Continue until you get to the “Generate your certificate” screen. Upload the .certSigningRequest file you created earlier and click generate. Download the generated ios_development.cer file.

Provisioning Profiles

8. Create a Provisioning Profile by clicking on “All” under “Provisioning Profiles” on the left menu, and then clicking the “+” symbol.

9. Create the Provisioning Profile for the App using the new .cer file (ios_development.cer). Download the .mobileprovision file.

Converting to P12

Back in your command prompt or terminal, run the following to convert the certificates:

openssl x509 -in ios_distribution.cer -inform DER -out ios_distribution.pem -outform PEM openssl pkcs12 -export -inkey ios_distribution.key -in ios_distribution.pem -out ios_distribution.p12 -passout pass:PASSWORD

You will now have the required .p12 and .mobileprovision files.

Step 2: PhoneGap Build

Now we use PhoneGap Build to generate the IPA.

  1. Go to build.phonegap.com and login or create an account.
  2. Go to Edit Profile, click the Signing Keys tab, and click “Add a key” under the iOS platform.
  3. Create a title, upload your .p12 file and .mobileprovision file.
  4. Set this key as default and click the lock button on the right side. Enter the same password you used in the OpenSSL step.

Since we are working on Ionic 2, create a zip file of the www folder of your project.

Upload this zip file to PhoneGap Apps. It will take some time and generate the IPA of your project.

Step 3: Installation via Diawi

The problem now is how to install that IPA on your mobile device. It will not work if you try to install it directly.

The Solution:

  • Upload your IPA to Diawi.com.
  • It will create a unique link.
  • Open that link on your iOS device using Safari (it will not work on Chrome).
  • Click install and enjoy your own created iOS app!
Birbal Kumar

Birbal Kumar is a senior developer specializing in mobile technologies and cross-platform frameworks like Ionic and React Native.