tovkal
(Andrés Pizà Bückmann)
1
I have the following code:
extension AssetGridViewController: PHPhotoLibraryChangeObserver {
func photoLibraryDidChange(_ changeInstance: PHChange) {
Task { @MainActor in
guard let changes = changeInstance.changeDetails(for: fetchResult) else { return }
fetchResult = changes.fetchResultAfterChanges
}
}
}
With Swift 6, this generates a compilation error: Main actor-isolated instance method 'photoLibraryDidChange' cannot be used to satisfy nonisolated protocol requirement. The error includes to fix-it suggestions:
- Adding
nonisolated to the function (nonisolated func photoLibraryDidChange(_ changeInstance: PHChange))
- Adding
@preconcurrency to the protocol conformance (extension AssetGridViewController: @preconcurrency PHPhotoLibraryChangeObserver {)
Both options generate a runtime error: EXC_BREAKPOINT (code=1, subcode=0x105b7c400). For context, AssetGridViewController is a regular UIViewController.
Any ideas on how to fix this?
Here is a sample project: GitHub - tovkal/PhotoSwift6: How to migrate PHPhotoLibraryChangeObserver to Swift 6?
1 Like
vns
2
Seems like a bug in Photos SDK to me. nonisolated there should be fine, given that observer called off main thread.
tovkal
(Andrés Pizà Bückmann)
3
Thanks! Yeah, I thought that, but wanted to ask somebody else in case I was missing something. I made a feedback for it (FB14101971)