The alignmentGuide modifier is @preconcurrency nonisolated. In Swift 6, I had to call a nonisolated function to calculate alignment, in which a certain @MainActor property was needed. That's why I tried to use a semaphore. I have switched back to Swift 5, since AVFoundation is not ready for Swift 6. The problem here is solved by removing nonisolated and semaphore. We may handle it after switching to Swift 6 in the future. Thanks.
Post
Replies
Boosts
Views
Activity
In class SystemPreferredCameraObserver of sample code AVCam: Building a camera app, the following
let newDevice = change?[.newKey] as? AVCaptureDevice
continuation?.yield(newDevice)
causes error in Xcode 16.1 RC:
Sending 'newDevice' risks causing data races
Task-isolated 'newDevice' is passed as a 'sending' parameter; Uses in callee may race with later task-isolated uses
What might be a workaround here?
I have a similar problem. My app saves data in SwiftData on an iPhone, and to a CloudKit private container. Works well for the iPhone. However, when running the app on an iPad signed in the same iCloud account, data are not fetched from CloudKit.
I try to save data off the main actor with the following actor
@ModelActor final actor DataActor {
init(container: ModelContainer) {
let context = ModelContext(container)
context.autosaveEnabled = true
modelContainer = container
modelExecutor = DefaultSerialModelExecutor(modelContext: context)
}
}
and fetch data with the main context, but no data are fetched. Data might not be saved by the above actor. After switching to data saving with the main context, it works.
With iOS 17 beta 6, Xcode 15 beta 6, my app crashes with:
dyld[600]: Symbol not found: _$s9SwiftData20DefaultModelExecutorC7contextAcA0D7ContextC_tcfC
No such problem with iOS 17 beta 5.
Xcode 15 beta 6 reports a new error for the array property:
CoreData: fault: One or more models in this application are using transformable properties with transformer names that are either unset, or set to NSKeyedUnarchiveFromDataTransformerName. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead. At some point, Core Data will default to using "NSSecureUnarchiveFromData" when nil is specified, and transformable properties containing classes that do not support NSSecureCoding will become unreadable.
CoreData: warning: Property 'dataSets' on Entity 'Station' is using nil or an insecure NSValueTransformer. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.
The documentation for ModelContext says it's Sendable, but when I use the context of the ModelActor above in another actor, I get a warning in Xcode 15 beta 4:
Non-sendable type 'ModelContext' in implicitly asynchronous access to actor-isolated property 'context' cannot cross actor boundary
Calling the run method causes a similar warning. What's happening?
Array property in SwiftData model seems to cause hang in my app, and the following errors:
fault: Either a non nil result OR an error
CoreData: Either a non nil result OR an error
fault: Either a non nil result OR an error OR an exception
CoreData: Either a non nil result OR an error OR an exception
Foundation._GenericObjCError.nilError
To share data between iOS/watchOS app and extension, @AppStorage fetches data automatically. With SwiftData, if outside SwiftUI View, the programmer needs to create a fetch descriptor and fetch data manually. Is SwiftData really better than @AppStorage in ObsersableObject?
After killing the app on iPhone, and launch it on iPhone, all strings are displayed correctly. However, launching it again in Xcode, all strings are capital again. It's a bug🐞
In the string catalog, links from keys to places where they are extracted would be helpful. I have keys like %@ and %1$@ %2$@ that I'd like to mark verbatim, but don't know where the sources are.
With @Observable or SwiftData model, how to share data between iOS app and widgets, if @AppStorage is unavailable?
I'm also stuck here. In my case it seems caused by the appearance of the model in the predicate of a fetch descriptor.
It seems the behavior of fallback automatic.
After initial display, setting position programmatically has no effect -- I wrote a feedback on this bug.
In my app, tapping the user location button has no effect either, but I couldn't create a simple app to reproduce it.
LocalizedStringKey is Sendable. How do the two differ? The documentation of LocalizedStringResource says: A reference to a localizable string, accessible from another process. Does it mean it's Sendable?