I have recently started working on developing a game prototype for my practice-based PhD. The game will be developed in Unity and exported to IOS mobile devices (iPhone and maybe iPad) and one of the main questions I had when embarking on this project was how to export from Unity to the actual device, especially with all the discussions about Apple’s complex authorization processes. Truth is that it does take a few steps to be able to directly export to the device and it may seem intimidating to the complete beginner but trust me, it’s not as complex as it looks after-all. You just need to know and follow all the different steps.
The reason why this is useful is cause it will allow you to export and test your game (or tests) directly on your device, instead of just relying on the Unity simulator.
The main issue, for the designer just starting with IOS development in Unity is that although the resources are all out there, they are often not all in one place so you’ll need to mix and match from various tutorials. Here I will try to summarize the whole process in one post. At least the one I followed to set this up and it has worked fine for me so far; so hopefully it will be of assistant to people in a similar stage of development or experimentation with Unity for IOS. Here we go…
1. Get Unity and the IOS exporter
If you haven’t done this already you first need to download Unity via the official website: https://store.unity3d.com/ There are two versions available, the free and the Pro version. I would suggest getting the free version which will give you access to a 30 day trial for Pro and the IOS / Android exporters. The current available version is 4.1.2 however an earlier version (3.5 or later) will work fine (however any earlier than that will cause issues later when you attempt to export to the device!).
From 21st May 2013 onwards you no longer have to pay for the mobile exporters as they now come free with the latest Unity version, so ignore the next paragraph and continue reading the next section. You can find out more about this here: http://blogs.unity3d.com/2013/05/21/putting-the-power-of-unity-in-the-hands-of-every-mobile-developer/
If you would like to have access to the exporters for more that 30 days then you will have to buy the exporters that come with the free version (priced at $400 each). If you are a student then you may be eligible for an educational price via Studica (in the UK but there are other licensed resellers for other countries via the official website); here it is: http://www.studica.com/us/en/unity
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 others. 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 by Apple 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 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 (up to 100), 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 screen is from a great tutorial I found on-line here