Hi all!
My new iOS app (first one in Swift and SpriteKit, was using ObjectiveC and Cocos2D before, a few years back) - got rejected with the dreaded "We were unable to review your app as it crashed on launch.",
That's especially bad news when it never ever crashed on any on our devices when testing (variety of phones, iPads and all sort of iOS) either in debug or release, before submission.
So no luck repro-ing!
The crashlog text file apple review team sent back, renamed as .crash, seems to open in Xcode (right click on it) when linked to the right project and seems to point in the leaderboard code fetching the local authenticated user's score. This is some code that I shamelessly copy/pasted from a StackOverflow page a few months ago, and seemed to work right away so moved-on back then, but something must be unsafe in there (sorry, bit of a rookie with Swift optionals etc).
Any help would be much appreciated as this code seems to work fine in debug, without warnings or anything, and also works fine in release using TestFlight - so we simply cannot repro the apple QA issue, and we need to fix it blind!
This is the function below that is crashing, right on the line that has the "{ player, _, _ in ":
func sync_hiscore()
{
if (GKLocalPlayer.local.isAuthenticated)
{
if #available(iOS 14.0, *)
{
GKLeaderboard.loadLeaderboards( IDs: ["HatStacker_LD01"] )
{ leaderboards, _ in leaderboards?[0].loadEntries( for: [GKLocalPlayer.local], timeScope: .allTime )
{ player, _, _ in // <<<< !!! CRASHES HERE!!
if ( player!.score > player_hiscore)
{
player_hiscore = player!.score
}
}
}
}
}
}
I've also attached the full crashlog if that's of any help!
Many thanks all, sorry for such a Swift rookie question, but to add to the confusion this is also the first time one of our apps gets rejected for such an obvious bad crash at launch, that no one has seen during our weeks of testing!
Any idea why it's only in release and only in the apple HQ/review env that we get that error? Could they have an invalid Game Center account that is confusing the "player" score fetching?
Cheers,
JBB