One of the first things I had to look into when I started developing my iOS game was how to export to the device so as to be able to test the game. Initially the process seemed long and complex and the main issue I had was that although the resources where all out there, they were not all in one place and so I had to mix and match from various tutorials. Here I will therefore summarize the process step by step in a single post. This is the process I followed to set everything up and has worked fine for me thus far; so hopefully it will be of assistance to people in a similar stage of development.
Here we go…
1. Get Unity and the IOS exporter
If you haven’t done this already you first need to download the latest version of Unity via the official website. There are two versions available, the free (http://unity3d.com/unity/download) and the Pro version (https://store.unity3d.com/), so you can choose one according to your needs. Since May 2013, the mobile exporters come with and you no longer have to pay for them.
2. Register for the Apple Developers program
The next thing that you will have to do is join the Apple developers’ program which is essential for setting up your development certificates among other things. Joining the program will cost $99 per year and you will need to register via the developers website here: https://developer.apple.com/programs/ios/ (Once you have registered and payed your fee, you will receive an activation e-mail which will allow you to fully join the program and give you access to all the features that you need).
3. Download and install XCode
Having joined the developers program the next thing to do is download and install XCode. This may seem confusing at first, as some of you will know that XCode is used for building native apps for the IOS. What happens is that Unity uses XCode as a mediator to push things into the IOS device, so you will not be actually working in XCode, all of the development will happen in Unity, however XCode is needed for exporting from Unity to the device. You can download XCode from https://developer.apple.com/xcode/ from the Apple Store. When done, make sure to install it before continuing.
4. Create a Developer Provisioning Profile
So far you should have downloaded Unity and XCode and activated your Apple developer program membership. Now, to export your game directly from Unity to the device you will need a Developer Provisioning Profile (which will authorize you to port the game you have developed or any tests, to your device). Apple offers two types of signed profiles, the Developer Profile, used for developing and testing (the one discussed here) and the Distribution Profile, used for submitting to the Apple Store (which is not covered in this post). However to set up the Developer Provisioning Profile you will need three separate things: to register your device / to set an App ID / and to get a Certificate.
All three can happen via your Apple Developer profile. So navigate to this address: https://developer.apple.com/ and then from the top menu go to Member Center. Use your Apple ID and Password to log in and then you will see a screen similar to this one:
Now go and select the Certificates, Identifiers and Profiles from where you can access and manage your provisioning profiles, apple IDs etc.
i. Register your Device
When in the Certificates, Identifiers and Profiles section, select Devices. The reason why this is needed is for Apple to be able to identify the specific device which will be used for testing. This will not alter any of your device’s settings and you can easily use the regular device you use everyday. To register your device hit the + button to add a new device. You will then need the device’s Name (which can be anything you want) and the UDID (which is the device’s unique ID). As you’ll see you can register more than one devices for testing, which could be useful if you’d like to test on more than one device (e.g. an iPhone and an iPad).
To find your device’s UDID you will need to connect your device to your computer, then open iTunes and hit the iPhone button (upper right corner of the interface) and you’ll see your device’s info including the name. Then hover over and click on the Serial Number which will change to a long identifier, the UDID.
This is the number you need so make sure to copy-paste it in the ID section in the Member Center Portal. Now review and register your device. Remember that once you register the device you can then only change its name and not the UDID.
ii. Set up an App ID
The next step is to set up your App ID. Still in Certificates, Identifiers and Profiles in the Member Center Portal select App IDs and hit the + button.
First provide the Description which can be anything you want as long as it helps you remember what the ID is used for. A good practice is to use a unique name for an app you plan to use and a generic one for a testing app. Next you need to set up the Bundle Identifier which takes the form of a reversed domain notation:
This is: com followed by your full name (if you are an individual developer) and your game’s name:
This type of Bundle ID is an Explicit one and is used for only one game. Therefore you will have to use a different name for every game you make. However it is useful and it allows you to access services like the ‘Game center’ and the ‘In-app purchases’.
On the other hand a Wildcard Bundle ID take the following form:
Here the game name is replaced by an asterisk. This format allows you to use one ID for multiple apps, without having to set a different name everytime, however it does not allow you to use certain services.
Now you have made your selections hit continue and confirm the App ID. Take a note of the Bundle ID as you’ll need to use it in Unity’s Build Settings later.
iii. Get a Developer Certificate
The first thing to do to get a Developer Certificate is to get a Certificate Signing Request through your computer. Go to Applications > Utilities > Keychane Access and then Preferences > Certificates. Make sure that both Online Certificate Status Protocol and Certificate Revocation List are OFF and close Preferences. Now in Keychane Access go to the Certificate Assistant and select Request Certificate from Certificate Authority. Provide the same details as the ones you used to register for the developer’s program and hit continue. Provide a name and save to Desktop. If asked choose: 2048 bits and RSA when you save.
You should now have a file with a .certSigningRequest prefix on your Desktop.
Now back Certificates, Identifiers and Profiles in the Member Center Portal, select Certificates > Development (as you are about to get a Development Certificate) and hit the + button to create one.
Choose to upload the Certificate Signing Request you have saved on your Desktop. Before you submit it, make sure to scroll down the page and find the WWDR Certificate in Intermediate Certificates. Download this as you will need it later!!
Now Submit and your Certificate Signing Request will be send to Apple and replaced by another one which you can download. This one is named: ios_development.cer
So now you should have two certificates on your Desktop. The ios_development.cer and the WWDR Certificate and you need to double-click on both of them to install then in Keychane Access. That’s it, you now have your developer certificate set up and installed.
iv. Create the Provisioning Profile
Having done the above three steps you can now go ahead and create your Provisioning Profile. Still in Certificates, Identifiers and Profiles in the Member Center Portal go to Provisioning Profiles > All and hit the + button to create a new profile.
Choose between a Development and a Distribution Profile (here we need a Development one!) and on the next screen choose the App ID, the device and the certificate associated to this profile (these are the ones you set up on previous steps). Finally name the profile and review the selections. When ready, hit Generate. Your new Provisioning Profile will now be available and you need to download it to your Desktop and install it. The profile will be a file with the prefix: .mobileprovision
Now start XCode and go Window > Organizer > Devices > Provisioning Profile and then double click on the profile downloaded on your desktop. It will be installed and should be visible in the Organizer view. This last step is very important as the profile must be installed into XCode to properly work!
Something Extra: While still in XCode if your device is not visible in the Devices’ view go to Window > Organizer > Devices and choose a device by name. You may have to select Use for Development in the process, and provide your developer’s log in details.
OK that was a long process but the good news is that you’re done!
You can now start working on your Unity game and be ready to export it once done!
Remember that you register your device and create a developer certificate only once, but you need to create a new App ID and a new Provisioning Profile everytime you make a new game.
5. Working in Unity
When you are ready to export your game, go to File > Build Settings and make sure you select IOS as your platform. Remember also to include the current scene to the exported game (use the Add Current button). Then hit the Player Settings button and go to Other Settings.
Set the Bundle Identifier to be the one you set up earlier ( com.YourName.TheGameName ) and you may also have to set the Target IOS Version to 6 (or the version your device is using). Leave everything else as default unless you have a reason to change it.
Now back to the Build Settings Window hit Build and save the project on its own folder.
Connect your device to your computer, open the folder and start the xcode project. You’ll see it opening inside XCode. Select your device from the top left corner in the XCode interface and then hit the Run button.
The project will be build on your device and run automatically (make sure your device is unlocked!).
And there it is! Your game is running on your IOS device.
p.s. the game that you see on the image above is from a great tutorial I found on-line here