Get Started with Play Games Services for C++ on iOS

Before you begin

This developer guide will show you how to compile and run a C++ game on iOS that uses the Google Play Games services API. Before you begin, download and configure the following requirements:

  1. Download the C++ sample games. This developer guide refers to the location of the samples on your machine as SAMPLES_DIR.
  2. Navigate to the SAMPLES_DIR/samples-ios/NativeGame/ directory, and install the GooglePlayGames pod by running the command pod install.
  3. Open the file NativeGame.xcworkspace in Xcode.

Step 1 (alternate): Set up your environment without CocoaPods

  1. Download the C++ sample games. This developer guide refers to the location of the samples on your machine as SAMPLES_DIR.
  2. Open the file SAMPLES_DIR/samples-ios/NativeGame/NativeGame.xcodeproj in Xcode.
  3. Drag the following files from the Google Sign-In iOS SDK into your Xcode project:
    1. GoogleSignIn.framework
    2. GoogleSignIn.bundle
  4. Drag the following file from the Google+ iOS SDK into your Xcode project:
    1. GoogleOpenSource.framework
  5. Drag the following files from the Play Games C++ SDK into your Xcode project:
    1. gpg.bundle
    2. gpg.framework
  6. Add the ObjC linker flag to the app target's build settings. In your target settings, select Build Settings > Linking > Other Linker Flags, then add -ObjC as a flag.

    Other Linker Flags: -ObjC
    
  7. Open your project settings and in the Build Phases tab, Link Binary With Libraries section, click the + sign and add the following frameworks:

    • AddressBook.framework
    • AssetsLibrary.framework
    • CoreData.framework
    • CoreLocation.framework
    • CoreMotion.framework
    • CoreTelephony.framework
    • CoreText.framework
    • Foundation.framework
    • MediaPlayer.framework
    • QuartzCore.framework
    • SafariServices
    • Security.framework
    • StoreKit
    • Security.framework
    • SystemConfiguration.framework
    • libc++.dylib
    • libz.dylib

Step 2: Set up your project Bundle Identifier

  1. Choose a Bundle Identifier for your project and replace the value in NativeGame > General > Bundle Identifier with your Bundle ID.
  2. In NativeGame > Info > URL Types there should be two URL Types. Navigate to the one with Identifier field com.google.BundleId and change the URL Schemes field to be the Bundle Identifier that you chose.

Step 3: Set up the game in the Google Play Developer Console

Create an entry for your game in the Google Play Developer Console. This enables Games services for your application, and creates an OAuth 2.0 client ID, if you don't already have one.

  1. Create an entry for your game by following the steps described in Setting Up Google Play Games Services. Create at least one leaderboard and one achievement. When asked to enter a Bundle Identifier, use the value you chose when setting up your Xcode project.
  2. Copy the iOS client ID you created from the Google Play Developer Console, then call IosPlatformConfig::setClientId() and pass in this ID.
  3. In your Xcode project, navigate back to NativeGame > Info > URL Types. In the URL Schemes field for the com.google.ReverseClientId identifier, replace YOUR_CLIENT_ID with the iOS client ID you just created.

Step 4: Run the sample

Using Xcode, run the sample on your iOS device.

Enviar comentarios sobre…

Play Games Services for C++
Play Games Services for C++