App is crashing when using "withCheckedContinuation" in Xcode 16 beta 5

We are experiencing an issue with withCheckedContinuation in our Swift project. Our implementation was working perfectly in a previous version of Xcode and continues to work in the simulator. However, it fails to work on a real device. Here’s a brief description of the problem: • Environment:

  • Xcode Version: Xcode 16.0 Beta 5
  • Swift Version: Swift 5
  • OS: IOS18 beta 5

• Problem: The code using withCheckedContinuation behaves as expected in the simulator but fails on a physical device. We are receiving a “bad access to memory” error when running on a real device.

• What We’ve Tried:

  1. Verified that the code works in previous Xcode versions.
  2. Tested on different simulators, where it runs without issues.
  3. Checked for any obvious errors in memory handling or threading.

Code Example: Here’s a simplified version of the problematic code:

    var body: some View {
        VStack {
            Text("Hello, world!")
        }
        .padding()
        .onAppear {
            Task {
                await self.checkTrialOrIntroductoryDiscountEligibilityAsync()
            }
        }
    }
    
    func checkTrialOrIntroductoryDiscountEligibilityAsync() async {
        return await withCheckedContinuation { continuation in
            checkTrialOrIntroDiscountEligibility() {
                continuation.resume()
            }
        }
    }

    func checkTrialOrIntroDiscountEligibility(completion: () -> Void) {
        completion()
    }
}
Answered by Dixit7405 in 803376022

This is fixed in the latest Xcode 16 beta 6 and later.

Same. It seems broken, I've been seeing a lot of comments from others so it appears widespread.

same problem here.

Has anyone filed a bug about this? If so, what was the bug number?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I have the same problem

Same here. But seems only happening on previous iOS 18.0 22A5307f and 22A5316j.

Again, has anyone filed a bug about this?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

This is fixed in the latest Xcode 16 beta 6 and later.

FB15135298

We shipped an app update built with Xcode 16 RC and are now seeing similar crashes in the wild.

They're all EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000004, and in each the first line in the stack trace is a call to withCheckedContinuation or withCheckedThrowingContinuation.

Everybody else encountering the issue seems to think it was fixed in Xcode 16 beta 6, so I'm surprised to see this. However, for the crashes where we have info on the specific build of iOS 18 are running beta 4 or earlier. Did this get fixed, but the fix also needed one of the later iOS 18 betas as well as a newer Xcode?

@pk_ I'm experiencing the exact same thing.

I cannot reproduce it myself but in my reports it shows as happening on an iPhone 12 mini with iOS 18 beta 2.

Same here, our app is randomly crashing for many users all of a sudden and all stacks show "withCheckedContinuation" in them. We changed no code other than compiling with Xcode 16

This is not fixed - we're using Xcode's latest update (Version 16.0 (16A242d)

Our macOS and iOS apps are both randomly crashing but always around withCheckedContinuation

We cannot reproduce this on any of our devices, but there are dozens of users with repeated crashed at launch

FB15151141 Xcode 16 built apps using withCheckedThrowingContinuation causing apps to crash on macOS 15 and iOS 18

We are seeing similar problems with our app released yesterday. Filed feedback 15152347

FB15151141

I don’t see a sysdiagnose, or even a crash report, attached to that bug. That’s gonna make it hard to investigate. If you have any extra info, please attach it.

FB15152347

Ditto.

Please have a read of Bug Reporting: How and Why? for my advice on how to file actionable bug reports.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

There are at least three threads running for this issue.

I’m going to focus my efforts on the first one.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

App is crashing when using "withCheckedContinuation" in Xcode 16 beta 5
 
 
Q