Let's assume that you just build your awesome game with Unity, and now you want other awesome people to play your awesome games. So you decide to publish your game in the PlayStore and the AppStore. You roam around Quora, StackOverflow, unity forums and many other sites to solve the issues you get while starting to build for android devices then finally complete it. Now comes the iOS part, you start your build and on the first try the build gets succeeded and your dopamine hits the peak making you very happy but the happiness doesn’t last for long as the next step is quite harder than you think THE XCODE PART. So today I will be sharing some of the research I have done, tips I have found and the problems I was able to solve while building for iOS devices.

Overview

You will encounter literally 0 errors while you are in your unity editor but after you start compiling the export in Xcode you will face more than 30 errors / get haunted by dependency errors if you haven’t followed all the steps carefully. Also, You might be able to find a dozen of solutions for a single error you receive while building for android in unity but it isn’t the same for ios builds. You will face more issues while building for IOS and also the answers in forums and other sites are usually very less, you might even need to fix some issues by yourselves.  So today to troubleshoot some of the issues you might face, we will be covering the following topics:

  • What are cocoa pods? and how to install them properly
  • Xcode versioning and .workspace files
  • Some of the common SDK issues and how to solve them

Cocoapods and how to install them properly

CocoaPods is an application-level dependency manager for Objective-C, Swift and any other languages that run on the Objective-C runtime. It’s a dependency manager that installs the required dependencies for your ios project like FirebaseSDK might require some dependency files for ios, the work of Cocoapods is to install all those dependencies so you wouldn’t have to manually go through all those SDKs and install them. Installation of cocoa pods is very important and plays a vital role in Xcode compilation. So let’s get into the proper Cocoapods installation and setup. If you have an external dependency manager in your project you might also have an option to edit its setting so you need to navigate to Edit>External dependency manager>Ios resolver > settings and make your settings similar to the image below:

After doing this and building the project unity might suggest you install Cocoapods through Unity itself ( DO NOT DO THAT ), doing this will create multiple issues and the Cocoapods won’t work properly so you will have to install it manually from https://cocoapods.org/. You can enter this command in your mac system to install Cocoapods.

$ sudo gem install cocoapods

After installation, you can enter pod --version to make sure you have installed it.

Moving forward you will need to navigate to your folder where you have exported your project’s build. After you have the folder you can open your terminal in that specific location and enter pod install in the terminal.

This will install all the dependency files needed for your project and generate a workspace file which will be needed later for Xcode.

Xcode versioning and workspace files

One of the key aspects of IOS development is Xcode versioning and the files that are generated by Unity for Xcode. Make sure you have the latest iOS Xcode and also you have the latest firmware in your iphone otherwise the app won’t build for real-time devices and produce too many errors. You also need to make sure that you have the correct SDK selected for your build. If you wanna build for a real ios device you will need to select the Device SDK in your unity build settings and if you want to build for a simulation device you will have to select the simulator SDK.

Common SDK issues while compiling:

Issues with Facebook SDK :

Facebook SDK in your game can cause many issues related to ios builds some of the common issues are :

  • “FBSharekit.h header file not found” -

Solution :

This is usually caused due to some faulty SDK compilation through unity so what you need to do is go in the unity assets folder : Assets/FBSDK/SDK/Editor/IOS and delete all the files inside this folder and restart unity. What this will do is it will re-import all the header files correctly.

  • “No known class method for selector updateUserProperties:Handler” -

Solution :

This is an issue that can be found in Xcode and this is an issue with the pod's version of your Facebook dependencies. In order to fix this, you can navigate to your Facebook SDK's dependencies.xml file which is located in the Assets/FBSDK/SDK/Plugins/Editor/Dependencies.xml . The file will look like this and make sure the version in the <iospods> section is not greater than version 9.

  • Module 'FBSDKCoreKit' not found :

Solution :

This is a quite simple issue but can cause too much headache if you skipped reading about the pods. To fix this issue you will need to manually check your podfile and see if the podfile has your pod “FBSDKCoreKit” or not if not you can add it to the file and hit pod install again to install the dependency. The pod file should be located in your Build folder and look like this:

Issues with Google SDK :

  • Issues with “Google mobile ads” and GAUDReward -

Solution :

To solve these issues you will have to re-import all your googlemobileads SDK  in unity to the latest version and build again. If you still keep getting errors you can follow the steps from the above custom podfile configuration and check if the pod and check if the pod ‘Google-Mobile-Ads-SDK’ is missing, if it’s not there you can add it and pod install for the dependencies.

  • “Firebase googleservices.plist is missing ” -

Solution :

In order to fix this issue, you will need to get your plist file from the firebase application section. In order to generate a plist file you will have to go to your firebase console, choose your app, create an ios app, click on the settings and you will be able to see a file with a download icon called “Google-services-info.plist”, you need to download it and place it in your unity project and build again or you can just copy the file and paste it in the builds folder and go on with Xcode.

For any questions, please leave a comment below. Thanks!