Unity5 iOS Development Resources

First I’m going to run through this tutorial about “Building your Unity game to an iOS device for testing”

Meta Tutorial

As I work my way through this tutorial I’ll post my findings here.

This tutorial shows how to test a game on iOS for free.  It talks about how if you want to publish to the App Store and do other similar things you may have to pay for a developer license.

Xcode has changed in small ways since this was written.  In the section called Building the sample project to your device using Xcode it says that in the top left you can open the project settings by clicking “Unity-iPhone” which didn’t work for me.  Instead I found project settings in the menu but I don’t think it is right because there is no “general” tab nor any “identity section”.  As a result I didn’t do any of this, but did “generate a new certificate” which was a simple two step process back in the same place where you added your Apple ID (Xcode->Preferences->Accounts)

When I plugged in my iPhone via usb (which I had never done before but only because its a new phone) it opened iTunes and made me verify that I wanted this trusted communication to take place then in Xcode it took a few minutes to “prepare it for debugging”.

Ok when I clicked build it failed and said that I needed to “select a development team in the project editor”.  I did some googling and things have really changed so it wasn’t easy to figure out what to do instead: 1. I found a “Build Settings” in the main editor window that had identity in it which let me select my identity at least.  After that it still required me to select the project on the left, then change the ‘target’ in the drop down just a bove the main editor window.  From there I could get to most of the settings it spoke of earlier.  I set the development team accordingly but then I had to go to the info tab and change the bundle id to something more unique than I had put in (per the tutorial I put com.unity3d.mobiledemo but thats not unique).

After that it still didnt launch so I had to go into my device in the general->device management settings and trust things from this developer.  But after that it totally worked!

Getting my Game to Build and play on my iPhone

This is an entirely different prospect.  I’m going to try doing the exact same things that I did with the other project but I know that my project has differences in its setup so I’m prepared to have to tweak things.

Update: Actually the build worked on the first try!  My game is running on my iPhone now!!!  YAY!

Touch Controls

To get Touch Controls working I may choose to download an asset from the asset store but first I want to see what I’m getting into.

Written tutorial on getting touch working:


This is a cool tutorial that I found while I was looking for what I need but it doesn’t do what I wanted so I’m bailing on it.

Official tutorial on touch controls:


This is part of the official rogue like tutorial but I don’t think it does what I am looking for either:

A youtube tutorial on the topic:

This one looks more along the lines of what I’m looking for.  he spends over 60s telling us which of his videos to watch but the code in this is really top notch, tight, elegant and clever.

It was quite good but I saw another video which led me to the asset store where I found this:

Asset Store Options:


This is free and should do the trick so I’m going to try it out.

Final Virtual Joystick Decision:

I ended up using the CN Controls from the Asset store.  It was really really easy.  I just dragged it into my canveas and changed Input.GetAxis to CnInputManager.GetAxis in my code then built and deployed to my iPhone and it TOTALLY WORKED!!   I’m glad I watched those videos because I now know that I could reproduce this on my own if I had to and I understand most of what these controllers are doing.


Problem with Shadows

I found a problem with shadows that only manifested on level 10.

Unity5 Shadows Problem
Scene 10 has problem Scene 9 doesn’t.

One solution I saw at the unity answers suggested increasing the scale of my game, but I don’t think thats wise because of this:

I did NOT end up finding any good solutions online and I believe there is somewhat of a bug but people are pretty religious about this topic for some reason and seem to either think that it “shouldn’t be a problem” because “why do you need more than that distance of shadows anyway!?!” which I think is pretty lame.  Regardless after hours of trial and error (including going back in time in git and copying the entire project and wiping things out behind the senes and re-generating them) I did find somewhat of a workaround.  First I switched build settings from iOS back to Mac/PC and then back to iOS which seemed to clear some shit out and at least made the shadows consistent from one scene to another.   Then I changed the shadow distance to 40 (Edit->ProjectSettings->Quality).  60 might have worked, 100 was pretty bad (My wife said it was Atari 2600 level!).  This does not look nearly as crisp as it looks when the shadow distance is 10 or when you are using the Mac/pc build setting but the lower you go the more disadvantages you get and this was the lowest I could go without seeing any dramatic disadvantages of shadows disappearing and popping up unnaturally toward the back of the screen (it still happens its just not too terribly unnatural).


Shadow Distance Differences (iOS Build Setting)
Shadow Distance Differences (iOS Build Setting)



Code Signing

Half of the times you build (after you’ve plugged your phone in again or done a clean build or for whatever reason) you have to go manually change the Team ID in Xcode but Unity does have a workaround.  In Unity->Preferences->External Tools there is an option to automatically sign your app but you have to put in a Team ID.  I had created one in Xcode (documented somewhat above) but putting that email or my name from there didnt work.  I had to dig deep to find the team.  Almost everyone online pointed me to something that doesn’t exist and said that at developer.apple.com you can find your team id, but since I have the free account atm thats not available from there (There is no Account.Membership section of my account on that site).  I was able to find the right Team ID using a real tricky bash script:


 security find-identity -v -p codesigning | awk -F \" '{if ($2) print $2}' | while read acct ; do security find-certificate -a -c "$acct" -p | openssl x509 -text | grep "^ *Subject:" | awk -v acct="$acct" -F , '{if ($3) {sub(/ *OU=/,"",$3);print $3","acct}}' ; done


I found that hidden at the bottom of this answer which says that it is a part of the keychain on my Mac (and apparently can somehow be looked up that way as well).

When you run that it takes a few seconds and then spits out the ID then a comma and then the name of the team account you’ve been using in Xcode.  Plugging the ID into Unity worked like a charm.



When you are done and you want to optimize here is an article all about optimization on mobile

And heres another with a real world game example of optimizing Shadowgun for mobile

Leave a Reply

Your email address will not be published. Required fields are marked *