All Questions
Tagged with concurrency swift
466
questions
0
votes
0
answers
20
views
Assertion Failure: Block Expected on Main Thread in Swift macOS App Using DispatchQueue [duplicate]
A user is experiencing a crash in my macOS app. It was written in Swift and developed using Xcode. The crash report indicates an assertion failure related to dispatch queues, specifically stating that ...
0
votes
1
answer
90
views
Swift 6: Error: Task or actor isolated value cannot be sent
I'm trying to resolve a compilation error: Task or actor isolated value cannot be sent when using Xcode 16.0 beta 3 with Swift 6 and Complete Concurrency enabled. My code:
import SwiftUI
@...
1
vote
1
answer
94
views
Passing argument of non-sendable type '(any URLSessionTaskDelegate)?' outside of main actor-isolated context may introduce data races
I am using SwiftUI and I declared the View as @MainActor to resolve some of the concurrency warnings. However, I still get the warning
Passing argument of non-sendable type '(any ...
0
votes
1
answer
83
views
ProgressView Not Updating During Data Parsing in SwiftUI
It's hard to reproduce the full code, but I'll try to explain the issue clearly.
I'm trying to display a progress bar view to show the status of parsing some data downloaded online. The function I use ...
1
vote
0
answers
213
views
Capture of 'self' with non-sendable type in a `@Sendable` closure
I'm working on a NetworkService class in Swift that uses async/await and observes network state changes. I'm converting the code to Swift 6.0 and I'm getting the following error on the line inside ...
-2
votes
0
answers
91
views
Asyncronous function don't run in the correct order [duplicate]
Why is my code not running in the correct order?
I can’t figure out why my code is not executing in the correct order. My downloadData function includes and should run the following three functions in ...
-1
votes
0
answers
93
views
Capture of 'self' with non-sendable type 'Type?' in a `@Sendable` closure
I have a warnings 'Capture of 'self' with non-sendable type 'Type?' in a @Sendable closure' for this code
func launchPairingAtCorrectStepAfter(timeout: TimeInterval) {
Timer.scheduledTimer(...
0
votes
1
answer
45
views
Conforming system type to a protocol with `@MainActor` isolation while disabling the concurrency check gives unexpected error
I have the following code that worked well:
protocol URLLauncher {
func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler: ((Bool) -> Void)?)
}
extension ...
0
votes
1
answer
102
views
How to convert AdMob `GADFullScreenContentDelegate` to Swift 6 concurrency
This is a similar problem to How to convert `VNDocumentCameraViewControllerDelegate` to Swift 6 Concurrency but one warning is new, so this may require different solution.
I have the following code:
@...
0
votes
1
answer
75
views
How to convert `VNDocumentCameraViewControllerDelegate` to Swift 6 Concurrency
So I have this code:
fileprivate class DocumentScanDelegate: NSObject, VNDocumentCameraViewControllerDelegate {
static let shared = DocumentScanDelegate()
var compressionQuality: CGFloat = 1
...
1
vote
1
answer
62
views
How to mark Vision text recognition result as Sendable in Swift 6
I have the following code. It simply run Vision API to get the text from the image. I use very simple GCD to dispatch the heavy Vision operation to the background queue, and then dispatch it back to ...
1
vote
1
answer
63
views
call swift Actor from AVAudioEngine (synchronous) code
I'm using apple's AVAudioEngine code like this:
var audioEngine = AVAudioEngine()
audioEngine.inputNode.installTap { [buffer, when] in
let waveform = myGetWaveform(buffer)
Task {
await ...
2
votes
3
answers
457
views
Swift 6: Capture of 'self' with non-sendable type in a @Sendable closure
Context
Consider this simple example, where we have an Actor and a Class which holds a reference to that Actor:
actor MyActor
{
func doWork() -> Int {
return 42
}
}
class MyClass
{
...
2
votes
1
answer
279
views
Strict concurrency and Swift 6 produces error when trying to convert PhotosPickerItem to Data
I have the below view where I want to load an image from gallery using PhotosPicker and display it to the user. I also want to convert the image to Data so I can store it in SwiftData database.
After ...
2
votes
1
answer
90
views
What is a "Concurrent Context"?
I currently reading a book "Modern Concurrency on Apple Platforms".
The book uses the term "Concurrent Context" many times without actually explaining the context of such an ...