Copy/Paste from Textview to Mail App Composer not working - MacCatalyst

I'm trying with the MacCatalyst app which has editor screen with UITextView.

Whenever I select some text [Attributed] & try to copy/paste ( using ctrl + c ) to another Mac app ( i.e Notes, Safari) it works well but if I try to paste it to Mail App's Composer, it doesn't work!

When selecting some text and copying, it prints this log in debug window:

Incorrect NSStringEncoding value 0x8000100 detected. Assuming NSASCIIStringEncoding. Will stop this compatibility mapping behavior in the near future.

When converting Attributed string to Data, I'm applying the Encoding options as below:

[NSAttributedString.DocumentAttributeKey: Any] = [
  .documentType: NSAttributedString.DocumentType.rtfd,
  .characterEncoding: String.Encoding.utf8 
]  

Still it doesn't seem to work. Anyone has any idea about this ?

Can you explain how you are putting the data on the pasteboard? Are you relying on UITextView to do the job for you, or do you have some code that does it?

In the MacCatalyst, Whenever the user copy something with ctrl + c key commands, data is sent to pasteboard by its own method

func copy() 

method. Even overriding copy() method isn't helping.

Where does your code above (i.e.)

[NSAttributedString.DocumentAttributeKey: Any] = [
  .documentType: NSAttributedString.DocumentType.rtfd,
  .characterEncoding: String.Encoding.utf8 
]  

appear in your program, and how is it being called?

Using this code to convert Attributed string into Data for making a pasteboard item.

extension NSAttributedString {
    var convertToData: Data? {
        let options: [NSAttributedString.DocumentAttributeKey: Any] = [
            .documentType: NSAttributedString.DocumentType.rtfd,
            .characterEncoding: String.Encoding.utf8 ]

        let range = NSRange(location: 0, length: length)

        return try? data(from: range, documentAttributes: options)
    }
Copy/Paste from Textview to Mail App Composer not working - MacCatalyst
 
 
Q