简体   繁体   中英

iOS CoreLocation (null) crash

I've been getting this error in my app through Crashlytics. I can't find where and how this crash occurs. Here is the log from Crashlytics:

Thread : Crashed: com.apple.main-thread
0  CoreLocation                   0x0000000183f62304 (null) + 60044
1  CoreLocation                   0x0000000183f230f0 (null) + 1436
2  CoreLocation                   0x0000000183f230f0 (null) + 1436
3  CoreLocation                   0x0000000183f2261c (null) + 1980
4  CoreFoundation                 0x0000000183754c9c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
5  CoreFoundation                 0x0000000183754940 __CFRunLoopDoTimer + 884
6  CoreFoundation                 0x0000000183752054 __CFRunLoopRun + 1520
7  CoreFoundation                 0x0000000183680dc0 CFRunLoopRunSpecific + 384

and this is also stated: Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x6136383561626000

Anyone can point me to the right direction? Thanks

The timer needs to be invalidated when the app is becoming inactive. In the applicationWillResignActive method, invalidate the timer object. You can reset it back in the applicationDidBecomeActive method. From the docs:

You should use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. An application in the inactive state should do minimal work while it waits to transition to either the active or background state.

If you are building an app that needs to collect location in the background, ensure that you location updates background capabilities are utilised.

You can also try out the HyperTrack SDK for iOS which will set this up and more for you so that you can build your location feature and not worry about this grunt work. (Disclaimer: I work at HyperTrack.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM