Search Unity

Building Unity Project with Google Play Services for iOS Tutorial

Discussion in 'iOS and tvOS' started by correia55, Apr 15, 2016.

  1. correia55

    correia55

    Joined:
    Feb 22, 2014
    Posts:
    7
    Software Versions:

    • iOS 9.3.1;
    • Mac OS X 10.11.5;
    • XCode 7;
    • Unity 5.3.4f1.

    After having the Google Play Services properly working for Android we were about to test those same services in iOS. These were the steps we had to take in order for it to work:

    1. Installing CocoaPods on Mac helps with the dependencies in the XCode project;
    2. After switching to iOS in the Build Settings from Unity, go to Window->Google Play Games->Setup->iOS Setup and set the variables as you did in Android but this time copy the Objective-C from the Get Resources in the Resources Definition then press Setup;
    3. Now you're ready to build a XCode Project. Get ready to face many problems;
    4. Download the SDK from https://developers.google.com/identity/sign-in/ios/sdk/ and copy GoogleSignIn.framework and GoogleSignIn.bundle to the folder of your project;
    5. Open your project in XCode and go to General->Linked frameworks and libraries and add the GoogleSignIn.framework with the Add Another option and locating the file in your folder;
    6. Then go to Build Settings->Build Option and set Enable Bitcode to No;
    7. Still in Build Settings, go to Linking and remove all the Other Linker Flags and add $(inherited);
    8. Go to Build Phases->Copy Bundle Resources and add GoogleSignIn.bundle with the option Copy items if needed selected;
    9. This next step is only necessary if you get the following error: "GIDSignIn.h" file not found. Click on it and it should show you the file where the error is occurring (the name of the file should be GPGSAppController.mm) change all imports that begin with "GID" to:
    10. #import <GoogleSignIn/GIDSignIn.h>
      #import <GoogleSignIn/GIDGoogleUser.h>
      #import <GoogleSignIn/GIDAuthentication.h>
      #import <GoogleSignIn/GIDProfileData.h>;
    11. Then we always got this error while linking "clang: error: linker command failed with exit code 1 (use -v to see invocation)" and after clicking it and seeing the Issue Navigator you can see that this results from "duplicate symbols for architecture arm64", which is solved by removing the GoogleSignIn.framework for the General->Linked frameworks and libraries, which we added in step 5. You may be wondering why did we add it to the libraries if in order for us to solve this error you need to remove it but the thing is if you don't add it you won't get past the "GIDSignIn.h" file not found error.
    This was the "easiest" way we found in order for us to build and deploy to an iOS device (iPad Air 2).
    If you have any suggestions on easier ways to do this we would appreciate it as this is a long process which delays debugging problems that are specific to iOS as we need to repeat almost every step every single time.

    Edit: Since the release of the new version of Google Play Games plugin for Unity (0.9.34), there seems to be no need for step 11.
     
    Last edited: Jun 27, 2016
    Tabu and antoniomva like this.
  2. gn.gametorque

    gn.gametorque

    Joined:
    Feb 13, 2015
    Posts:
    26
    I did the same steps as you mentioned. But I am getting this error.

    clang: error: no such file or directory: ';'

    I am using same Unity Version, MAC OS X and XCode version
     
  3. gn.gametorque

    gn.gametorque

    Joined:
    Feb 13, 2015
    Posts:
    26
    I resolved it... while adding $(inherited); I added Semicolon too... I had to add this without samicolon
     
  4. linithos

    linithos

    Joined:
    Apr 9, 2010
    Posts:
    7
    Hello @correia55

    When you said "Installing CocoaPods on Mac helps with the dependencies in the XCode project;" you mean create de Podfile, install pod and open the project created? or I just skip those steps and go to your step 2?

    I've installed CocoaPods and I already followed the instructions to build in iOS as the guide says but I get the "GIDSignIn.h" file not found error. So I found this post and I did every step but I got clang: error: linker command failed with exit code 1 (use -v to see invocation)" but instead the duplicate issue I got multiple missing google frameworks. I don't know what to do.... can you help me?

    Thank you
     
  5. swifer07

    swifer07

    Joined:
    May 27, 2013
    Posts:
    12
    mochadwi20 likes this.
  6. mochadwi20

    mochadwi20

    Joined:
    Dec 19, 2016
    Posts:
    9
    Hello, could you elaborate more. How do we achieve this action? :)
     
  7. correia55

    correia55

    Joined:
    Feb 22, 2014
    Posts:
    7
    We haven't worked tried the procedure in a long time, not sure if it still works.

    The code you need is available at the Google Play Console > Game Services > [Select Your Game] > [Achievements or Leaderboards] > Copy Resources > Tab Objective-C.
     
    mochadwi20 likes this.
  8. mochadwi20

    mochadwi20

    Joined:
    Dec 19, 2016
    Posts:
    9
    Okay, thanks :))) I'll try to inform it, if this succeed or not.

    Or, is there any alternative rather than Google Play Games for iOS?

    Recently, doing some porting game from Android to iOS, the legacy code have anything with Google.
     
  9. correia55

    correia55

    Joined:
    Feb 22, 2014
    Posts:
    7
    Apple has a similar platform to Google Play Games, its called Game Center.
    If you're using Google Play Games in Android and then want to use Game Center in iOS, the easiest way we found was to add NO_GPGS in the Scripting Define Symbol, as described in here.
     
    mochadwi20 likes this.
  10. mochadwi20

    mochadwi20

    Joined:
    Dec 19, 2016
    Posts:
    9
    Well, then we should migrate to Game Center :)) Thanks for your recommendation :)