Adding the Game Kit Framework

Problem

You have set up your project and want to start incorporating Game Center APIs into your app.

Solution

Add the Game Kit framework to your app as demonstrated in the Discussion section.

Setting the Bundle Identifier of an app in Xcode 4

Figure 1-5. Setting the Bundle Identifier of an app in Xcode 4

Discussion

To use Game Center’s capabilities, you must link your application against the Game Kit framework. Assuming you have created an Xcode project already for this app, import this framework into your Xcode project as follows:

  1. Click on your project (which should have a blueish icon) in Xcode. Once you see your project’s settings, click on the target that has to be linked against the Game Kit framework.

  2. On the top of the screen, select Build Phases and then expand the Link Binary With Libraries box, as shown in Figure 1-6.

  3. Click on the + button, select GameKit.framework from the list, and press the Add button, as depicted in Figure 1-7.

Build Phases for an iOS app

Figure 1-6. Build Phases for an iOS app

Adding the Game Kit framework to an iOS target

Figure 1-7. Adding the Game Kit framework to an iOS target

Game Kit is now added to your project. Now you have to decide whether or not using Game Kit is a requirement in your application. iOS versions older than 4.1 do not support Game Center ...

Get Writing Game Center Apps in iOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.