App is crashing when using "withCheckedContinuation" in Xcode 15 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 DTS Engineer in 804111022

Folks, thanks for sharing the latest info. And please do update this thread if you see this crash on the released iOS 18.0 or later.

Share and Enjoy

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

Same. I believe you mean Xcode 16 beta 5, can update the title so other people having same issue can join.

Same. On Xcode 16 beta 5

This is the same issue as on your other thread, right?

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

Sorry, just to point out that this is not fixed, see latest remarks: https://developer.apple.com/forums/thread/761654

There are at least three threads running for this issue.

I’m going to focus my efforts on the first one, that is, this thread.

Share and Enjoy

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

@DTS Engineer thanks for the replies!

Reupping my feedback (FB15135298) over in this thread. Crash reports are about all I've got for you but happy to attach more to that feedback if it will help.

Now we're a little ways into the iOS 18 rollout, and I'm not seeing an explosion of crashes from this issue. (I do continue to see a few users encountering it though). And, I still haven't seen any crashes for which I can get an iOS build number that were running beta 5 or later.

So my thinking is that this must have gotten fixed in the later iOS 18 betas, there's some pool of folks still on earlier betas out there, and they are the source of these reports. Would love confirmation if that's the case!

@pk_ I've gone through every crash report and indeed they're all on build 24A5298h, which is beta 4! Coincidentally I'm also not seeing an explosion of crashes (which I was dreading) so it's likely a few dozen users on the same older build in our case.

The same on iOS 18 - Crashlytics doesn't give us the build number of the OS so it wasn't obvious that they may all have been on older betas.

We can probably safely assume this isn't happening on later versions of macOS 15.

What threw me off is a few users crashing on macOS 11 and 14 but these are now most likely because of something else.

@Smithers awesome, glad to hear you're finding the same thing. Yeah I sure wish Crashlytics gave build numbers, would have saved a lot of effort on this one.

Folks, thanks for sharing the latest info. And please do update this thread if you see this crash on the released iOS 18.0 or later.

Share and Enjoy

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

My app had instant, repeating (5+ per user), withCheckedThrowingContinuation crashes when building off Xcode 16 (non-beta) for iOS 18.0 users. Had to do an emergency release with Xcode 15 and that seems to resolve it.

Issue in RevenueCat (popular SDK): https://github.com/RevenueCat/purchases-ios/issues/4177

I would also like to mention my report filed August 12th, 2024 regarding the same issue: FB14768097

The issue does not happen on latest 18.1 Betas.

I hate to be that guy, but @DTS Engineer , are we sure the patch was applied to the 18.0 train and not removed in the release version?

are we sure the patch was applied to the 18.0 train and not removed in the release version?

Honestly, I’m not sure about anything O-: I’m largely going off the reports I’m seeing from you folks, and those are rather mixed.

Notably, the two bugs referenced above (FB15135298 and FB14768097) aren’t marked as resolved, but it’s possible that changes were made via other channels.

Has anyone managed to distill this down into a small test project that reproduces the issue with released tools on a released OS?

Share and Enjoy

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

Hello! Is there any new information regarding this issue? We are seeing some crashes using XCode 16.0 (16A242D). All of them are from users in iOS 18.0.0. We have not been able to reproduce the error ourselves so far :(

Is there any new information regarding this issue?

I saw this go by on Swift Forums this morning.

Share and Enjoy

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

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