UIDocument crashes when overriding writeContents(_:) in Swift 6

I’ve been trying to set up a UIDocument and override writeContents(...). This works correctly in older projects, but I haven’t been able to get it working in my new iOS 26 app using Swift 6.

To troubleshoot, I tested the Particles demo and successfully overrode writeContents there. However, as soon as I switch that project to iOS 26 and Swift 6, calling save; which triggers writeContents, causes the same crash.

    override public func writeContents(
      _ data: Any,
      to url: URL,
      for _: UIDocument.SaveOperation,
      originalContentsURL _: URL?,
    ) throws {
...
    }

Thread 10 Queue : UIDocument File Access (serial)

Annotating writeContents with nonisolated appears to resolve this issue. However, as a Swift6 newbie, I’m not sure why there isn’t compile-time enforcement of the nonisolated requirement for writeContents.

UIDocument crashes when overriding writeContents(_:) in Swift 6
 
 
Q