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:
Verified that the code works in previous Xcode versions.
Tested on different simulators, where it runs without issues.
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()
}
}
Post
Replies
Boosts
Views
Activity
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()
}
}