Questions tagged [swift6]
The swift6 tag has no usage guidance.
swift6
17
questions
0
votes
1
answer
102
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
@...
3
votes
1
answer
147
views
Closures in actors: Sending 'nonSendable' risks causing data races
Why is this not allowed in Swift 6 (Xcode 16 Beta 3)?
class NonSendable { }
actor MyActor {
func foo() {
let nonSendable = NonSendable()
for _ in 1...3 {
// ✅ ...
-1
votes
1
answer
83
views
Why does calling an async actor function in a MainActor result in a compiler error in Swift 6 to file a bug?
I have the following MainActor class:
import Foundation
import os
@MainActor
public class UserData: ObservableObject {
let userDataLogger = Logger(
subsystem:
"com.author....
1
vote
0
answers
239
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 ...
0
votes
1
answer
105
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:
@...
1
vote
2
answers
165
views
Set UnsafeMutablePointer pointee from a different actor
UnsafeMutablePointer is not Sendable anymore and in Xcode 16 Beta using the build setting 'Strict Concurrency Checking', setting the pointee of the pointer from another actor (rightfully?) gives a ...
3
votes
1
answer
160
views
How to access a static property Swift 6 concurrency-safe?
My app uses a class A and its subclasses SubA_x.
A has a static property serialNumber that is only modified by class A when a subclass is initialized.
It sets a property let name so that every ...
0
votes
0
answers
50
views
How to migrate PHPhotoLibraryChangeObserver to Swift 6 and Strict Concurrency Checking?
I have the following code:
extension AssetGridViewController: PHPhotoLibraryChangeObserver {
func photoLibraryDidChange(_ changeInstance: PHChange) {
Task { @MainActor in
guard ...
2
votes
3
answers
480
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
{
...
1
vote
0
answers
68
views
Use a `Protocol` instead of concrete @MainActor class produces an error
Could anyone please clarify how the concurrency checking works in my case? I have an actor that calls the foo method of a @MainActor class:
actor MyActor {
let property: MainActorClass
init(...
-1
votes
1
answer
102
views
How to initialize a singleton with a model container in SwiftUI?
How do I initialize a singleton with a model container while keeping the ability to use @Environment(\.modelContext) private var context throughout my application?
Currently, I'm doing the following ...
1
vote
0
answers
77
views
Main actor-isolated static method issue
I have just installed Xcode16 beta, enabled strict concurrency + Swift version 6 SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
I am maintaining (and developing) a SwiftUI macOS app for ...
2
votes
1
answer
122
views
How to handle Non Sendable Struct in Async/Await?
I have a View that can let the User pick an Image. I bind the PhotoPicker to "item" a PhotoPickerItem. But in the "getImage" Function i get an error: "Sending 'photoPickerItem....
0
votes
0
answers
80
views
How to update SwiftData store from actor?
How do I go about saving the new FHIRObservations to SwiftData? My current approach await self.model?.updateObservations(newObservations: fhirResources, deletedObservations: uuidsToDelete) leads to a ...
0
votes
1
answer
21
views
How to make the LinePlot feature of Swift Charts dynamic and animated?
I'm trying to get the LinePlot feature from Xcode 16 to work. I tried the example code and it works, but I'm struggling to make it work interactively and animated.