Chapter 5, continuations leaking

Since I can no longer run Xcode 13.x on my Mac, I’m forced to run Xcode 14.

With Xcode 14 and Swift 5.7, the book example for moving Core Location to async/await no longer works.

I cannot get the location, and when I try, I get this error:

SWIFT TASK CONTINUATION MISUSE: shareLocation() leaked its continuation!
2022-09-29 10:21:48.412482-0500 Blabber[16012:215787] SWIFT TASK CONTINUATION MISUSE: shareLocation() leaked its continuation!

I would be really nice to get this code working again, I don’t really want to move on with this being broken. Is anyone available to help with this?

I got it working!

Inside of ChatLocationDelegate, in the initializer, you need to add these 2 lines to the end…

        manager.startUpdatingLocation()
        continuation.resume(returning: manager.location ?? CLLocation(latitude: 1.0, longitude: 1.0))
4 Likes

Thank you for looking into this, I’ll make a note that we need to update this for Xcode 14

@perlguy I managed to reproduce here, it seems CLLocationManager just deadlocks since the iOS16 update. I shifted around the code around the initialization here ios16 updates by icanzilb · Pull Request #26 · raywenderlich/mcon-materials · GitHub and that seems to have fixed the issue, we’ll update the book materials soon.

1 Like