Translate

Saturday, April 14, 2018

Developer tips - Visual Studio - Apple iOS certificates

Disclaimer !
This article is based on tests/research/finding at April 2018. Things can change.

 
In order to develop code for iOS (or also Mac) you need to have certificates and provisioning profiles from Apple.
In other words the application will be able to be installed and run on the device ONLY if Apple recognize the certificate.
The certificates are so a very intimate and integral part of the development and preparation of an app for iOS.

This issue is more broad than just Visual Studio (Xamarin), is valid as well for direct Xcode development.
I did put Visual Studio as starting point because I'm currently working mainly on that, but really this article has almost nothing to do directly with Visual Studio.
On the development machine is actually Xcode that take care of handling the generated certificates and keys.
Visual Studio simply pick them up from Xcode.

Let see this aspect of the Apple ecosystem little bit more closely.

Apple iOS Certificates 


Really, typical pain in the ... neck.
Put simply, in order to develop and release an app, you MUST be registered as developer at Apple and you MUST have certificates/provisioning profiles for specific jobs.
Most of them can be free, others require you to pay some money.  I'm not discussing the economic/fees aspect here.
Tons and tons of documents, blogs, books, etc. really cover this issue, but still the issue is quite complex.
Sometime I'm working on that, then I stop for months doing something else and when I come back I forgot about lot of things.
Very annoying. Time to recap .. again these notes are mainly for me but hopefully can be useful to somebody else.

Anyway, let see some topics.

Important ! The information in this article are updated on April 2018 !
I can't guarantee Apple or others changes the way to do things or the graphic/functionality of web sites.
Another things ... I'm not trying to duplicate what thousands of other people already did write nor to cover every possible aspect.

What we need ?


The provisioning profiles are the important piece we need in order to build an application.
There are two types of provisioning profiles :
  • Development
  • Distribution
The Development Provisioning profile allows to build an app for debug (see the build types article) and release.
They usually include a Development list of allowed devices.

The Distribution Provisioning profile can be for Distribution (final release on Apple Store) or Ad Hoc.
The main difference is that the Ad Hoc still contains a list of allowed devices where the app can run.
Note that a Distribution provisioning profile allows ONLY to load the application on the Apple Store !

To load the application directly or via external meaning (like Test Fairy or iTunes) requires to have a Distribution Ad-Hoc provisioning certificate.

In order to generate a Provisioning profile we need to have a certificate.


Certificates management


Ok, I'm assuming you have an Apple ID.
The first thing to do is to go to manage the certificates and other bureaucratic stuff at the Apple Developer website.
The Apple developer website is where we can create/remove certificates and create Provisioning certificates.

Generally speaking every time you create a certificate or provisioning certificate, you MUST download it on YOUR machine (a Mac) and process it using Xcode.
i.e. download the file and open it with Xcode.  This USUALLY is enough !
Sometime however is possible something goes wrong ending up to play also with the Key manager of the machine.

Once logged in go on the Account tab


The account tab has a menu on the left. Click over Certificates, IDs and Profiles.
This is the section where we can create certificates.

Again on the left there is a menu :


We have :
  • Certificates
  • Keys
  • Identifiers
  • Devices
  • Provisioning Profiles
First of all we need to have a certificate for what we need to do.
For example, development or distribution or adhoc.
To create a certificate go on Certificates and click on the + on the upper right corner of the section.
The select the type of certificate you want and follow the instructions.
Note, this involve to create keys on your local machine (create a Certificate Signing Request) and do some back and forth with the Apple website.

Once you have your certificate, you can download it on your machine.
Then we need to create a Provisioning Profile.

Provisioning profile


What is a provisioning profile ?
A provisioning profile is a collection of digital certificates that uniquely identify a company or development team.

We can have Development and Distribution provisioning profiles.

A Development provisioning profile identify a developer or a development team, a set of allowed devices and enables a device to be used for testing.

A Distribution provisioning profile identify a company who release the application and does not limit the usage to a list of devices.

To generate/manage a Provisioning profile on the menu on the left, select Provisioning Profile, All.

When creating the Provisioning profile you will need to have at least one certificate for the specific function.
In other words you need to have a Development certificate in order to create a Development profile and a Production certificate to create a Distribution profile.

Like before, click on the + on the top right corner of the section to generate and then download on your machine the Provisioning profile generated.



No comments:

Post a Comment