In iOS 18 beta 5 version, setting the conversion to NSAttributedString using [.documentType: NSAttributedString.DocumentType.html] occasionally causes crashes

In iOS 18 beta 5 version, setting the conversion to NSAttributedString using [.documentType: NSAttributedString.DocumentType.html] occasionally causes crashes

The same issue was encountered in previous versions. However, after running the code on the main thread, it no longer crashed. But after upgrading to the iOS 18 beta 5 version, it occasionally crashes even when running on the main thread.

How can this issue be resolved?

Answered by DTS Engineer in 799350022

How can this issue be resolved?

The best thing you can do is to make sure and file bug reports with as much information as possible, including crash reports, sysdiagnoses, and test projects that reproduce the issue.

— Ed Ford,  DTS Engineer

How can this issue be resolved?

The best thing you can do is to make sure and file bug reports with as much information as possible, including crash reports, sysdiagnoses, and test projects that reproduce the issue.

— Ed Ford,  DTS Engineer

I had also issue. I fixed it for me by replace utf8 with unicode

        let htmlData = NSString(string: modifiedFont).data(using: String.Encoding.unicode.rawValue) ?? Data()
        let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
            .documentType: NSAttributedString.DocumentType.html,
            .characterEncoding: String.Encoding.unicode.rawValue,
        ]

In iOS 18 beta 5 version, setting the conversion to NSAttributedString using [.documentType: NSAttributedString.DocumentType.html] occasionally causes crashes
 
 
Q