App Rejected - Crashes on Launch unable to replicate

414 views Asked by At

I have an app that works well when I test on device, however after submitting to Apple for review, I was told the app crashes at launch. Further investigation of the symbolicated crash log showed that there was something wrong with below function (line 131: self.highScore = leaderboardRequest.localPlayerScore.value)

Anyone see this before? I'm thinking it has something to do with 64bit architecture but I can't replicate the error.

func getHighScore(leaderBoardId: String) {

    let localPlayerID = GKLocalPlayer.localPlayer().playerID

    let leaderboardRequest = GKLeaderboard(playerIDs: [localPlayerID]) as GKLeaderboard!
    leaderboardRequest.identifier = leaderBoardId
    if leaderboardRequest != nil
    {
        leaderboardRequest.loadScoresWithCompletionHandler({ (scores:[AnyObject]!, error:NSError!) -> Void in
            if error != nil
            {
                //handle error
                log.debug("error retrieving score")
            }
            else
            {
                log.debug("here we go: \(leaderboardRequest.localPlayerScore.value)")
                self.highScore = leaderboardRequest.localPlayerScore.value //line 131
                NSNotificationCenter.defaultCenter().postNotificationName(AUTHENTICATED_NOTIFICATION, object: self)
            }
        })
    }
}

Crash Logs are below:

{"app_name":"MyGameApp","app_version":"1.1","bundleID":"com.aaapps.MyGameApp","adam_id":933686335,"os_version":"iPhone OS 8.1.1 (12B435)","slice_uuid":"00f078c2-cb60-3dec-b4d5-27187cb55a13","share_with_app_devs":false,"build_version":"1","is_first_party":false,"bug_type":"109","name":"MyGameApp"}
Incident Identifier: 5010EF12-A30A-41E2-9FEA-2335C25EB3DC
CrashReporter Key:   e3d10d2ccd5af0e83a5e75453e737ab344eca9e4
Hardware Model:      xxx
Process:             MyGameApp [2917]
Path:                /private/var/mobile/Containers/Bundle/Application/D3BD0802-4F20-4C10-AC6A-E0EACECFEE44/MyGameApp.app/MyGameApp
Identifier:          com.aaapps.MyGameApp
Version:             1 (1.1)
Code Type:           ARM-64 (Native)
Parent Process:      launchd [1]

Date/Time:           2014-12-01 09:56:07.167 -0800
Launch Time:         2014-12-01 09:56:01.608 -0800
OS Version:          iOS 8.1.1 (12B435)
Report Version:      105

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001002682e0
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib              0x00000001002682e0 _TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_ + 144
1   libswiftCore.dylib              0x00000001002682dc _TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_ + 140
**2   MyGameApp                             0x00000001000f8c48 MyGameApp.GameKitHelper.(getHighScore (MyGameApp.GameKitHelper) -> (Swift.String) -> ()).(closure #1) (GameKitHelper.swift:131)**
3   MyGameApp                           0x00000001000f9060 reabstraction thunk helper from @callee_owned (@owned [Swift.AnyObject]!, @owned ObjectiveC.NSError!) -> (@unowned ()) to @callee_owned (@in ([Swift.AnyObject]!, ObjectiveC.NSError!)) -> (@out ()) (GameKitHelper.swift:123)
4   MyGameApp                           0x00000001000f3188 partial apply forwarder for reabstraction thunk helper from @callee_owned (@owned [Swift.AnyObject]!, @owned ObjectiveC.NSError!) -> (@unowned ()) to @callee_owned (@in ([Swift.AnyObject]!, ObjectiveC.NSError!)) -> (@out ()) (GameKitHelper.swift:0)
5   MyGameApp                           0x00000001000f9088 reabstraction thunk helper from @callee_owned (@in ([Swift.AnyObject]!, ObjectiveC.NSError!)) -> (@out ()) to @callee_owned (@owned [Swift.AnyObject]!, @owned ObjectiveC.NSError!) -> (@unowned ()) (GameKitHelper.swift:0)
6   MyGameApp                           0x00000001000f91f8 reabstraction thunk helper from @callee_owned (@owned [Swift.AnyObject]!, @owned ObjectiveC.NSError!) -> (@unowned ()) to @callee_unowned @objc_block (@unowned ObjectiveC.NSArray!, @unowned ObjectiveC.NSError!) -> (@unowned ()) (GameKitHelper.swift:123)
7   GameCenterFoundation            0x000000018d45e3c0 __39-[GKDispatchGroup 
1

There are 1 answers

0
barn On
if (error != nil) {
    println("Error: \(error!.localizedDescription)")
  }else if (scores != nil) {
    let localPlayerScore = leaderBoardRequest.localPlayerScore
    println("Local player's score: \(localPlayerScore.value)")
  }

you must add

if (scores != nil)

because you scores array is nil ( you have no scores before someone submit one) leaderboardRequest.localPlayerScore.value is nil and crash

Barn