How to Fix a IOS Does Not Exist in the Namespace Google Play Games in Unity Ask

When you’re building a cross platform Unity game with support for both Android and iOS, things usually go smoothly until they don’t. That’s what happened to me recently while working with the Google Play Games plugin. Out of nowhere, I hit this compile time error:

Assets/GooglePlayGames/Platforms/PlayGamesClientFactory.cs(31,40): error CS0234: The type or namespace name 'IOS' does not exist in the namespace 'GooglePlayGames'. Are you missing an assembly reference?

If you’ve encountered this same issue, let me walk you through what caused it, how I fixed it, and how you can improve your cross-platform code to avoid future surprises.

Code That Trigger the Error

Here’s the original code in my project that caused the issue:

using System;
using UnityEngine;
using UnityEngine.SocialPlatforms;
using GooglePlayGames.BasicApi;

namespace GooglePlayGames {
internal class PlayGamesClientFactory {
internal static IPlayGamesClient GetPlatformPlayGamesClient() {
if (Application.isEditor) {
return new GooglePlayGames.BasicApi.DummyClient();
}
#if UNITY_ANDROID
return new GooglePlayGames.Android.AndroidClient();
#elif UNITY_IPHONE
return new GooglePlayGames.IOS.IOSClient(); // Error here
#else
return new GooglePlayGames.BasicApi.DummyClient();
#endif
}
}
}

Why This Happen

The error message tells us that the compiler can’t find the GooglePlayGames.IOS namespace. This can happen for several reasons:

  • The iOS support files from the plugin were never added to the project.
  • The plugin was updated or modified, and iOS support was removed.
  • You’re using a version of the plugin that only supports Android.
  • The #elif UNITY_IPHONE directive is incorrectly compiled due to platform settings.

In my case, the plugin simply didn’t include iOS support out of the box anymore, which means I was referencing code that no longer existed.

How I Fix It

Since I wasn’t using Google Play Games on iOS (I use Game Center instead), I swapped out the broken reference with a DummyClient:

#elif UNITY_IOS
return new GooglePlayGames.BasicApi.DummyClient(); // Simple fix

This fixed the error and kept my build working.

Optional Enhancement Write More Resilient Code

Hard-coding platform specific client references is risky. I decided to clean things up and make the code more robust:

using System;
using UnityEngine;
using UnityEngine.SocialPlatforms;
using GooglePlayGames.BasicApi;

namespace GooglePlayGames {
internal class PlayGamesClientFactory {
internal static IPlayGamesClient GetPlatformPlayGamesClient() {
if (Application.isEditor) {
Debug.Log("Using DummyClient for Editor");
return new DummyClient();
}

#if UNITY_ANDROID
Debug.Log("Using AndroidClient");
return new Android.AndroidClient();
#elif UNITY_IOS
Debug.LogWarning("iOS Play Games support not available, using DummyClient.");
return new DummyClient(); // Or plug in Game Center client here
#else
Debug.Log("Using DummyClient for unknown platform");
return new DummyClient();
#endif
}
}
}

This version adds logs for clarity and avoids referencing missing classes.

Conditional Compilation for iOS Support

If you plan to reintroduce an IOSClient later, you can wrap it with your own define to prevent this issue from happening again:

#if UNITY_IOS && PLAY_GAMES_IOS_SUPPORT
return new GooglePlayGames.IOS.IOSClient();
#else
return new DummyClient();
#endif

Then just define PLAY_GAMES_IOS_SUPPORT in your project settings when needed.

Extra Add Useful Logging

I also added basic logging to help debug what platform client was being returned:

Debug.Log("Using AndroidClient");
Debug.Log("Using DummyClient for iOS");
Debug.Log("Using DummyClient for Editor");

This is especially helpful during testing on multiple platforms.

Final Thought

This error was a good reminder that cross platform development requires cautious handling of platform specific code. By abstracting your platform logic, adding safety checks, and avoiding unnecessary references, you can make your Unity project much more stable and future-proof.

Related blog posts