iOS Code Signing - A Complete Walkthrough
6:47 PM
Sometimes deploying your app on your iPad/iPhone can be such a mess. Apple somehow makes things so complicated for a novice user to understand and use it. There are so many articles out there related to code signing, but sometimes its not very easy for users to understand what is happening where.
To run the app on our development devices, we first need to create a development certificate and then once that is done we need to code sign our app. You can either do it through Xcode in your organizer tab or from the Member Center in the developer.apple.com. I will go with the latter.
1. Click on “Certificates, Identifiers and Profiles”.
2. Click on “iOS Apps” because we want to create our certificate for iOS apps.
3. Click on “Certificates”
4. Under the Certificates tab you can see the categories for which you can create your certificates. In our case, we want a certificate to be able for our apps to run on devices during development. Hence click on “Development”
5. You can create the certificate from here by clicking on the little “+” sign.
6. Select the “iOS App Development” option
7. When you click next it now asks you to create a CSR File. For this purpose, do the following:
c. Fill out the email address you specified in your developer account. Give a common name to your private key. Leave the CA email address field empty. Click on Request is saved to disk. Tick the box stating “Let me specify key-pair information”
d. Click on “Continue” and it will generate the .certSigningRequest file. Save it in an appropriate folder.
e. You get a “Key Pair information” screen. Leave it as it is (Algorithm -RSA) and click Next.
f. Specify your keychain password(your machine password) and then you are done.
8. Now that you have created the .certSigningRequest file, upload this file as asked.
9. Click Generate and download the certificate.
10. Double click it and it will automatically be added to your keychain.
11. In your key chain click on “Certificates” and you will see the new certificate.
You now have your certificate on your machine for you to work with.
Whatever the application that we wish to run on the development devices, we need to also create an App id for them. Lets look how. I am assuming you have already created your application on Xcode.
1. Go to Certificates, Identifiers and Profiles > Identifiers >All
2. Click on the “+” button to add an identifier to your app
3. Give a description to your app. (eg: Name followed by device type etc)
4. Leave the app id prefix as it is if something is already there. Or click on “Generate new”. This will be the first few letters of your Identifier
a. To find your Bundle Id go to XCode > Your Project
Note: Sometimes you might find a wierd set of characters in the suffix of the bundle id. I changed it to be like the one you can see down.
Note: If you haven’t already created your app, then just remember the App id and add this into the info.plist file. The bundle id and the app id should match.
6. In the App services, tick whatever your app makes use of.
7. Confirm your app id and then click on Submit
The App Id is also set. To run this app, we need devices. We should register devices that we are going to deploy our application to. We will look at how to do this.
1. Go to Certificates, Identifiers and Profiles > Devices >All
2. Click on the “+” button to add a device.
3. Specify a name to your device
4. You also need to find the UDID(Unique Device Identifier) of your device. This is the 40 character hex string that uniquely identifies your device. The easiest way to find this is to …
a. Go to Itunes > devices
Now you also have your devices set-up. The final task is to set up your provisioning profile.
What is a provisioning Profile?
It is something that allows your application to run on your devices. It is a collection of your iOS development certificate, UDID and your App Id. Without one, you cannot install your apps on your development devices.
Let us look at how to create a provisioning profile.
1. Go to Certificates, Identifiers and Profiles > Provisioning Profiles > All
2. Click on the “+” button to add one profile.
3. Select the “iOS App Development” option.
4. Select the app id you previously created.
5. Select your certificate that you just created
6. Select the device you set up. (You can create this provisioning profile to work on any number of devices that you register )
7. Give a name for your profile and generate the provisioning profile.
8. You can now download this profile and install it by clicking on it.
9. You can notice that this has been added to your Xcode
So with my understanding on how this works, I am going to pen down a walkthrough to guide users on how to do this process.
For the purposes of this tutorial, I am not going to go into the part where you sign up for the iOS Developer Program. I am going to assume that you have already done this.
Okay so lets get started.
You have created an iPad app and have been running this on the simulator for quite long that you decide you want to run it on real iPad devices. One main piece of knowledge I got while working on an iOS project was the fact that you can never rely completely on a simulator. Its fast and it does your work properly. But it is not the simulator that you will be using if you are reach a wider user base. You need to test it on real devices because, by nature, they are slow and some functionalities don't really run well on simulators (inApp Purchasing).
Okay so lets get started.
You have created an iPad app and have been running this on the simulator for quite long that you decide you want to run it on real iPad devices. One main piece of knowledge I got while working on an iOS project was the fact that you can never rely completely on a simulator. Its fast and it does your work properly. But it is not the simulator that you will be using if you are reach a wider user base. You need to test it on real devices because, by nature, they are slow and some functionalities don't really run well on simulators (inApp Purchasing).
What is Code Signing?
A code signing entity is the name given to the set of credentials that Apple issues for you. It’s a private-public key. This is stored locally(on your Mac), and when at other times you wish to do your development on other Macs, you would have to re-use this code signing identity on them as well.Why is the Certificate a big deal?
Its all about trust! Apple knows your the rightful owner by the certificate you possess. They and the world will know you as the developer that built the app. And that nobody else falsely tried to develop or distribute without your knowledge.
Lets look at how to create a certificate now.
*For all parts of this tutorial I assume you have signed into your developer account and is in the "Developer Program Resources" screen as shown below.
1. Click on “Certificates, Identifiers and Profiles”.
2. Click on “iOS Apps” because we want to create our certificate for iOS apps.
3. Click on “Certificates”
4. Under the Certificates tab you can see the categories for which you can create your certificates. In our case, we want a certificate to be able for our apps to run on devices during development. Hence click on “Development”
5. You can create the certificate from here by clicking on the little “+” sign.
6. Select the “iOS App Development” option
7. When you click next it now asks you to create a CSR File. For this purpose, do the following:
a. On your Mac, go to Applications > Utilities > Key Chain Access
b. From File , click on “Request Certificate from Certificate Authority”
b. From File , click on “Request Certificate from Certificate Authority”
c. Fill out the email address you specified in your developer account. Give a common name to your private key. Leave the CA email address field empty. Click on Request is saved to disk. Tick the box stating “Let me specify key-pair information”
d. Click on “Continue” and it will generate the .certSigningRequest file. Save it in an appropriate folder.
e. You get a “Key Pair information” screen. Leave it as it is (Algorithm -RSA) and click Next.
f. Specify your keychain password(your machine password) and then you are done.
8. Now that you have created the .certSigningRequest file, upload this file as asked.
9. Click Generate and download the certificate.
10. Double click it and it will automatically be added to your keychain.
11. In your key chain click on “Certificates” and you will see the new certificate.
You now have your certificate on your machine for you to work with.
The next question will be, if you want to be able to use this certificate on another Mac machine, what would you do? Would you have to go through all these steps? Click here to learn how to do this.
Lets Set up the App Id
Whatever the application that we wish to run on the development devices, we need to also create an App id for them. Lets look how. I am assuming you have already created your application on Xcode.
1. Go to Certificates, Identifiers and Profiles > Identifiers >All
2. Click on the “+” button to add an identifier to your app
3. Give a description to your app. (eg: Name followed by device type etc)
4. Leave the app id prefix as it is if something is already there. Or click on “Generate new”. This will be the first few letters of your Identifier
a. To find your Bundle Id go to XCode > Your Project
b. Click on the Application and then Click on the target
c. Find your Bundle Identifier. Generally, your Bundle id should be in the format <com>.<company name>.<app name> .
Note: Sometimes you might find a wierd set of characters in the suffix of the bundle id. I changed it to be like the one you can see down.
Note: If you haven’t already created your app, then just remember the App id and add this into the info.plist file. The bundle id and the app id should match.
6. In the App services, tick whatever your app makes use of.
7. Confirm your app id and then click on Submit
What about my devices?
The App Id is also set. To run this app, we need devices. We should register devices that we are going to deploy our application to. We will look at how to do this.
1. Go to Certificates, Identifiers and Profiles > Devices >All
2. Click on the “+” button to add a device.
3. Specify a name to your device
4. You also need to find the UDID(Unique Device Identifier) of your device. This is the 40 character hex string that uniquely identifies your device. The easiest way to find this is to …
a. Go to Itunes > devices
b. Make sure you are on the Summary tab and more importantly make sure your device is connected.
c. You may either see text that says “Serial Number” or “Identifier(UDID)”. If it’s the former, click on it so that it changes to “Identifier”.
d. You can copy the UDID now.
5. Click on continue once you specify the device details and your device is registered.
5. Click on continue once you specify the device details and your device is registered.
What is a provisioning Profile?
It is something that allows your application to run on your devices. It is a collection of your iOS development certificate, UDID and your App Id. Without one, you cannot install your apps on your development devices.
Let us look at how to create a provisioning profile.
1. Go to Certificates, Identifiers and Profiles > Provisioning Profiles > All
2. Click on the “+” button to add one profile.
3. Select the “iOS App Development” option.
4. Select the app id you previously created.
5. Select your certificate that you just created
6. Select the device you set up. (You can create this provisioning profile to work on any number of devices that you register )
7. Give a name for your profile and generate the provisioning profile.
8. You can now download this profile and install it by clicking on it.
9. You can notice that this has been added to your Xcode
As the final step, do this too:
Under Build settings in XCode, set the code signing identity you just created.
This should be done to both Targets and Projects.
Okay, so we have also created our provisioning profile and ta-da thats it. The app should work fine on your device now (Don't forget to select the device option to run it on the device while running it through Xcode).
Under Build settings in XCode, set the code signing identity you just created.
This should be done to both Targets and Projects.
Okay, so we have also created our provisioning profile and ta-da thats it. The app should work fine on your device now (Don't forget to select the device option to run it on the device while running it through Xcode).
22 comments
I expected you'd write something wicked someday, but never thought you will write development stuff in here.. gone to the next level eh :P
ReplyDeleteWicked?????
DeleteJust wanted to try and see ;)
http://www.drjoanna.com.au/wp-content/uploads/2013/02/butter.jpg
ReplyDeleteThanks you !!!
ReplyDeleteWelcome :D Glad to be of help :)
DeleteHi, I'm currently working on a multi platform game and we are using a MacBook to make the iOS build. At one point the provisioning profile was not updating properly on the IDE, so I noticed it was duplicated from the mac, I erased it and the certificate too on keychain, but now I doesn't seem to reinstall the recently downloaded certificate, theres nothing on the keychain.
ReplyDeleteXcode meanwhile says there are 3 development certificates but the status is "Missing private key". Any ideas? Thanks
Nice Article! On the same topic,Airsign can resign any iOS Apps (IPA / Xcarchive files) and upload it in your Dropbox for over-the-air installation. It is really straightforward if you just want to send an adhoc/inHouse version to your testers !
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteNice Blog Post. I would like to add here new thing that you all should know about IOS Development Company which offers complete solutions of development. I like such kinds of companies which are best in services. If someone know such kind of other companies then please do share here.
ReplyDeleteIllegitimate child.. You do not have to carry that baggage.
ReplyDeletethanks for share this fantastic blog
ReplyDeletereally informative thanks
Facebook and IPhone Apps
Facebook Apps Developer
IPhone Apps Developer
Thanks for sharing such useful information. The information provided is very very niche and this information is not available so easily. Therefore I thank the writer for the useful input.
ReplyDeleteit is a useful writing. the information provide in the blog can not be found online other than this blog.
ReplyDeleteiphone application development
This comment has been removed by the author.
ReplyDeletewow, great post! your post is really informative and helpful. thanks for sharing.
ReplyDeleteThank you, the guidelines where helpful. :)
ReplyDeletethanks for sharing this nice information.... IPhone mobile app development Hyderabad
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for sharing your valuable information about iPad/iPhone development. I am agree with you, Apple somehow makes things so complicated for a nerd user to understand, I am also an iPhone developer, and I am active on many iPhone developer forum for exploring latest technologies and tactics.
ReplyDeleteThanks for sharing this valuable information, it was very useful.
ReplyDeleteIOS Development
great article!!!!!This is very importent information for us.I like all content and information.I have read it.You know more about this please visit again.
ReplyDeleteApp Development Course Online
Hi I'm a PHP Developer and Was searching for ios code signing online and I found this very interesting article thank you Krishnakripa for sharing this wonderful article.
ReplyDelete