Very odd.
As far as I can see the only piece of code in the whole of my GameScene.swift - or even the whole project - calling loadEntries (to fetch hiscores) is my sync_hiscore() function.
How is it getting called right after the GameKit inits?
In theory my sync_hiscore() function is only called when we're well into my game main loop, navigating the main menu, so it will be a few seconds before the user presses the start button. The "app start" frame 16 would be long gone, no?
I added a "fatal error()" in my sync_hiscore2() function to see if it was somehow called at launch time and crash on boot. But no, nothing.
But then if I try the press "start game" it does crash right away as it reaches that "fatal error" line, but the crash report looks nothing like the one apple sent, as it is clearly showing it went into my function after I press start etc.
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libswiftCore.dylib 0x18166d534 _assertionFailure(_:_:file:line:flags:) + 576
1 HatStacker 0x1028e46cc GameScene.sync_hiscore2() + 224
2 HatStacker 0x1028d66e4 GameScene.start_game() + 1420
3 HatStacker 0x1028b5aa0 GameScene.menu() + 5640
4 HatStacker 0x1028b1d84 GameScene.update(_:) + 308
This confirms the fact the apple review team isn't crashing that way, pressing the button, which syncs the score, calls my LoadEntries with the dodgy completion handler.
They are crashing earlier, in a different manner.
So, correct me if I'm wrong here: they seem to be indeed crashing on very early on launch (app start is still within 16 frames) and somehow as the various systems kick in, Swift traps some bad code in my leaderboard completion handler, situated inside a function that is never called, but related to a similar LoadEntries function called by something else?
Sorry for being thick here! I am very confused.
Do I fix my function with a safer completion handler anyway? It cannot hurt I guess, as that way if it gets called for any reason, it will survive?!
I've attached the original symbolicated crash report, in case it can shed some extra light on why the loadEntriesForPlayers gets called, then the completion handler in my function gets called right after?
Sorry for all these questions... Many thanks for you help Quinn, much appreciated!
Cheers,
JBB
HatStacker_build4_symbolicated.crash