I am using Google Play Games plugin for Android, but how to build without it for iOS

I want to include a highscore list in my game and I want one highscore list using Google Play services for Android and one highscore list using Game Center for iOS. For the iOS version i use the built in social API of Unity and for the Android version i use this plugin:

Problem is, when I try to build in Xcode I am getting a lot of errors because the Google Play Games plugin does also support iOS but i did not install all required libraries etc, because I don’t want to use it on iOS. E.g. the RegisterMonoModules.cpp contains a lot of references to Google Play Games symbols - but I don’t know how to exlude them (other than manually modifying that file).

Did I miss something or do I really have to include additional SDKs in Xcode for a plugin that i am not using on that platform?

From the docs on the GitHub page:

This plugin can be disabled for
building on iOS. What this means is
that the libraries and references
originating in the GooglePlayGames
namespace are excluded from the build.
It does not affect code that has been
written by you, such as calls to the
GPGS API.

To disable the Google Play Game
Services in the iOS build, open the
iOS player settings. Then in the
“Other Settings” panel, find the entry
named “Scripting Define Symbol” and
add a symbol named: NO_GPGS (case
sensitive).

I tried this and it worked perfectly!

I’ve fixed it. It was a pain. FYI, I have both Google Play and GameCenter plugins installed, and I want neither showing up in my iOS project. Here are instructions:

  1. Go into Assets/Plugins/iOS and delete the following files (for me, this was every file in that directory):

Google Play

GPGSAppController.h
GPGSAppController.m

Game Circle

AmazonInsightsSDK.a
GameCircle.a
GameCircle.h
libGameCircleUnityProxy.a
GameCircle.bundle
  1. Stop the source code from generating any native function bindings:

Google Play

  • Open all the code files in Assets/GooglePlayGames in a code editor.
  • Find and replace in all files UNITY_IPHONE with IGNORE_IOS_PLZ (or any other define that doesn’t actually exist).

GameCircle

  • Open all the code files in: Assets/Plugins/AmazonCommon and Assets/Plugins/AmazonGameCirclePlugin.
  • Find and replace in all files UNITY_IOS with IGNORE_IOS_PLZ (or any other define that doesn’t actually exist).

And everything should run! FYI, I am having issues getting GameCenter to work now “application is not recognized by Game Center” and I’m not sure if this is related. If it is, I will update this post with fixes for that too.

I think what you’re looking for are Preprocessor definitions.

It sounds like you’re probably using C#, so you can do things like this:

#if UNITY_IPHONE
//do iphone things here
#elif UNITY_ANDROID
//do android things here
#else
//do error things here
#endif

The code between the #if UNITY_IPHONE and the #elif will only be compiled if it is an iOS build.

Does this answer your question?