iPhone Game Development - Chris Craft [19]
FIGURE 2.7
The GLPaint example running in the iPhone Simulator. Starting with the iPhone SDK 3.0, you have an option to “shake” the iPhone Simulator.
Play around with the example and the iPhone Simulator to start familiarizing yourself with the tools. You can rotate the device and use your mouse to draw on the screen as you would if you were touching the device. There is even an option to rotate the device under the iPhone Simulator Hardware menu. The screen on the iPhone Simulator is screaming “SHAKE ME!”. At the time of writing, 3.0 did not include support for the accelerometer in the iPhone Simulator, so you may not be “shaking” anything until you install this example on your device.
Note
A new feature of the iPhone SDK 3.0 allows you perform a “shake gesture” in the iPhone Simulator. Unfortunately, this is not the same as accelerometer support in the iPhone Simulator and will not work in the GLPaint example yet. Shake is a new gesture that joins a family of gestures, including swipe and pinch. To perform the shake gesture in the iPhone Simulator, go to the menu bar and choose Hardware⇒Shake Gesture.
Running the sample on your iPhone or iPod touch
If that did not get you a little stoked, then this next exercise will. You are going to run this same application on your iPhone or iPod touch. The first thing you will need to do is plug your device into your Mac. If you have Xcode open, you can open Organizer to confirm that it has been detected. To open Organizer, choose Window⇒Organizer from the Xcode menu (Figure 2.8). If your device has been detected, you will see your device name in the left pane with a green dot beside it.
While in Organizer you should go ahead and install the Provisioning Profile on your device. In Chapter 1 we talked about creating Provisioning Profiles; now it's time to use them. Download the Provisioning Profile that you created for your device. Once the download has completed, drag the Provisioning Profile onto the Xcode icon on your Dock. Head back into Organizer and make sure your Provisioning Profile has been added to your device in the Provisioning section. If not, click the + (plus) button and click the file you just downloaded.
Now that your device has a Provisioning Profile installed, you can deploy, execute, and debug the sample directly on your device. Even though you have installed the Provisioning Profile on your device for development, you also need to tell your application about the Provisioning Profile. This pairing allows you to test applications on your device while also ensuring that you cannot freely distribute your app without going through the App Store. This may seem like a pain, but today distributing through the App Store has major advantages.
FIGURE 2.8
Organizer is your tool for installing Provisioning Profiles on your development devices, installing the beta version of the iPhone OS, and more.
Now you are ready to walk through the steps necessary to run the example on your device:
1. Launch Xcode if you have not already done so.
2. Set the Overview pull-down menu to the version of the SDK that you wish to test against, as shown in Figure 2.9.
3. Choose Groups & Files⇒Resources and add a new file.
4. From the New File dialog box, choose iPhone OS⇒Code Signing⇒Entitlements (Figure 2.10) and click Next.
Figure 2.9
Selecting the Active SDK that you will be using for your project
Figure 2.10
Choosing the Code Signing Entitlements template from the New File dialog box
5. You will now be in the New File dialog box. In the File Name edit box, change the name from untitled.plist to Entitlement.plist and click Finish (see Figure 2.11).
Figure 2.11
Specifying a name for the Entitlements file you are creating
6. Select the newly created Entitlements.plist and make sure the property get-task-allow is checked off (Figure 2.12).
Figure 2.12
Configuring Code Signing Entitlements
7. Choose Groups & Files⇒Targets⇒GLPaint.
8. Click the Information icon in the toolbar.
9. If not