I am in the middle of struggling with Swift6 and facing the same compile error, too.
URLSession methods demand @Sendable in their closures.
How about using Kingfisher's downloder?
import Kingfisher
...
let downloader = ImageDownloader.default
downloader.downloadImage(with: url) { result in
switch result {
case .success(let value):
//value.originalData is Data
...
contentHandler(bestAttemptContent)
case .failure(_):
contentHandler(bestAttemptContent)
}
}
...
or using NSData.init?(contentsOf url: URL)
(This runs synchronously, not an ideal solution but very simple one)
https://developer.apple.com/documentation/foundation/nsdata/1413892-init
At least, this compile error vanishes with any of these.
(Currently we have too many compile errors with Swift6.)
Topic:
App & System Services
SubTopic:
Notifications
Tags: