Reporting score to GameCenter in iOS 9 (xCode 7.1.1)

So I have a finished game, which I'm just tidying up before submitting to the App Store.

Since I finished the majority of the coding, I've updated xCode to 7.1.1 and my device to iOS 9.1 from 8.1.


The first thing I've learnt is there's no Sandbox toggle in Game Center (which is what I've mostly always used with no problems)

Now, when I run the application, when it comes to reporting a score using this code:


    -(void)reportScore{
        GKScore *this_score = [[GKScore alloc] initWithLeaderboardIdentifier:_leaderboardIdentifier];
        this_score.value = gameScore;
       
        [GKScore reportScores:@[this_score] withCompletionHandler:^(NSError *error) {
            if (error != nil) {
                NSLog(@"%@", [error localizedDescription]);
            }
        }];
        NSLog(@"Reported to Game Center...");
    }


I get this error printed to the console:

    *** Terminating app due to uncaught exception 'GKInvalidArgumentException', reason: 'A GKScore must specify a leaderboard.'
    *** First throw call stack:
    (0x184e60f48 0x199a13f80...  ...0x1000d9748... ...0x19a2628b8)
    libc++abi.dylib: terminating with uncaught exception of type NSException


which states, a `GKScore` must specify a `leaderboard`...


I'm confused, because up until I updated to iOS 9, this worked fine.


I've been reading a bunch about the merging of sandbox in iOS 9, but I don't understand all of it.

From what I can gather, it's merged into real-life accounts, all sandbox data is deleted and testing is done on real leaderboards? I may be wrong. Like I said, I'm not 100% about this.


How can I solve this problem?

Maybe I need to specify my LeaderboardIdentifier locally?


**UPDATE**

This is even worse than I thought...

Some of my apps that are in the App Store now crash when trying to open/submit to Game Center when the player dies and a score is trying to be submitted...?


I only just thought to test them since reading this


Is there a cleaner or more updated method of implementing Game Center?

Hi Aaro


Sounds pretty frustrating 🙂 Can you please file a bug on this? That's the best way for us to help you. We need to know the bundle IDs of the apps you are having issues with, the leaderboards you are having problems posting to, and if possible the user IDs of one or more players that had the issue. That will allow us to get take a deeper look as to what is happening.


Regarding Sandbox... There is no longer a sandbox switch because we no longer have a separate sandbox environment. All pre-release testing is now done in the same production environment that all other games live in. Perhaps this article can shed some light on this change.
https://developer.apple.com/library/ios/technotes/tn2417/_index.html


Thanks 🙂

Reporting score to GameCenter in iOS 9 (xCode 7.1.1)
 
 
Q