Unity iOS Getting Started

So I haven’t been posting here for a while, but I have had all kinds of issues. Issues I have solved in the past, and for SOME SORT OF REASON, I haven’t been writing down. So from now on, I will be writing a blog post about every issue I have. That way if I have the issue again in the future. Here’s the solution, and hopefully it will help someone else!

Enter (errrrrrrr) Unity iOS

Today’s problem is brought to you by a new project we are developing for a client. It’s a mobile game that’s supposed to be running in both Android and iOS (MAYBE windows phone?? am trying to ignore it for now, you know, like everyone else).

Now I have done my fair share of android development (on windows), and I thought, hey I got a Mac, it should be as simple as clicking build.

ARC

Guess what? It’s not that simple. After going through the whole process of becoming an approved developer for iOS (I went through it twice, once for myself, and another time for the Company) that you can find here http://docs.unity3d.com/Manual/iphone-GettingStarted.html

I thought I was set, we already had the project running on android, so why would it be different?

First Build, Boom.  Build Succesful. AWESOME I thought.

The Xcode project would no open. That’s ok, I tried opening it manually, it opens fine

Command  + B (a nice shortcut to remember!) starts building, and it gave me this error:

Error in Xcode!

Error in Xcode!

On this problems, don’t be afraid to use the proposed fix, it’s actually as simple as double clicking (not sure if it’s going to be fixed in the next Unity version, downloading as I speak). Once it’s fixed, try to build it again (from XCode, not from unity!)

ARC forbids explicit message send of ‘autorelease’

ARC error

This issue was tricky to catch, because a lot of people in the Interwebz (helpful strangers) say that you should deactivate ARC (this can be done through the Build Settings). But guess what? This is not the solution, the real solution is adding a compilation flag to the files that give you issues.

We are using an asset from the AssetStore (https://www.assetstore.unity3d.com/9) called social plugin, that enables different platforms to use several different social plugins, this is the root of our compilation issues! (https://www.assetstore.unity3d.com/en/#!/content/15066).

The file that was giving us the issues was the FbUnityInterface.mm so we are going to add the no ARC flag to this file ONLY, how do we do this? We go through the build phases setting in the target.

Select the file and add the flag!

Select the file and add the flag!

Now look for the file in the Compile Sources and add:

-fno-objc-arc

As a compiler flag for the specific file that we know it’s giving us issues, it should look like this

Add the -fno-objc-arc flag

Add the -fno-objc-arc flag

 

AND WE ARE … not done yet… what?

 

Linker Error

(null): Symbol(s) not found for architecture arm64

This was the worst error, since it was related to how iOS works internally, but don’t worry! We are going to fix it (though we  have to go through the whole process again). Basically, what this error is saying is that we are missing a reference to a library that the plugin needs to compile. So to fix it, we need to add a couple of library that handle social stuff and messaging!

This is done inside unity,specifically this 2 libraries:

Need to add the Social and the MessageUI libraries, remember to apply it!

Need to add the Social and the MessageUI libraries, remember to apply it!

 

And now we build, AGAIN.

Build Succeeded!

 

THINGS TO REMEMBER

This was quite a while of work and researching, but finally seeing it running on an iPad Air 2, and knowing it will run with no issues on all other platforms gives me quite a bit of pleasure :).

Now you need to keep in mind that some errors may happen because:

  • Scripting Backend is not set to IL2CPP (this is set in the player settings)
  • Universal Architecture is not set in the player settings
  • Some files may be missing
  • Provisioning File or Certificate may not be set properly
  • Unity Version might have a bug

So be sure to always check this first! And hopefully your app will be up and running in no time!

Don’t hesitate to write me if you have doubts!

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

One thought on “Unity iOS Getting Started

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.