I'm developing an iPhone game with Game Center integration. The game is being built as Debug (not release/distribution). On the simulator, Game Center always uses the sandbox properly. On the iPhone device itself, it will go for a few days using the sandbox, then suddenly decide to use the real Game Center servers (which results in an error, because my game has not yet been released). It's been avoiding the sandbox for several days now, and I hate testing on the simulator. Any idea how to once and for all make it use the sandbox during development?
Here's the relevant quote from the Game Kit Programming Guide:
As a developer, your Game Center account may be logged into either Sandbox for testing, or into the live environment but not both. To change which account you are logged into, switch to the built-in Game Center app and log out, then run any Game Center enabled app. If that app is provisioned for development, enter your test account information to log into Sandbox. Otherwise, enter your live account information to log into the live environment.
As far as I can tell, my app is being provisioned using a Developer Provisioning Profile. The build mode is set to Debug. I have signed out of Game Center on the device. I also tried signing out of the Store for good measure.
I restored my iPhone from a backup. This had the effect of removing all provisioning profiles and the game itself. I then used Xcode to install and run the game, and sandbox magically started working again. I'm not sure if the full restore was required, or just removing the game. I had previously tried removing all provisioning profiles, and that didn't work. I suspect the restore was likely necessary in my case.
Edit: It might be my imagination, but iOS 4.2 seems to have improved the stability of the sandbox somewhat. I've noticed that the device seems to log me in to the sandbox even on other release games on my device (games by other companies). It seems to permanently keep me in sandbox mode until I sign out. I haven't done any more experimentation to test this in 4.2 since I am loathe to restore my device again if it stops working.