Add Game Center Capability Using Xcode

To enable Game Center in Hog Dice, you need to add the Game Center capability to the Xcode project and target.

Open the hog project in Xcode.

In the Project Navigator, select the hog project file, and in the Project Editor, select the hog target. Now, switch to the Signing & Capabilities tab and you’ll see something like the image shown.

images/AddingLeaderboardsAndAchievements/pre-add-capability.png

As you learned in Chapter 1, Creating Scenes with Sprites and Nodes, the Bundle Identifier must be unique when publishing a project to the App Store. Because the Bundle ID, net.justwritecode.hogdice, already exists on my Apple developer account, be sure to change the Bundle ID to something else (if you haven’t done so already)—preferably a domain that you own.

With the Bundle ID set to something unique, the next step is to add the Game Center capability.

Before you begin, verify that you have the Automatically manage signing option enabled. When that option is enabled, Xcode will handle setting up the profiles, app IDs, and certificates you’ll need to successfully publish to the App Store.

To add a new capability, click the + Capability button in the top-left corner of the Project Editor window, and you’ll see something like this:

images/AddingLeaderboardsAndAchievements/capabilities-gc.png

Here, you can select the capability you wish to add. Scroll down to the Game Center capability and double-click the row to add that capability. Because the Automatically manage signing option is enabled, Xcode creates the necessary profiles, apps IDs, and certificates needed to work with and support Game Center.

If everything went as expected, you’ll see the Game Center capability listed at the bottom of the Signing & Capabilities tab.

Your next task is to set up the app in App Store Connect.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset