I am writing an app where users can dynamically generates a pdf file and sends it to people using Mail. I used this code for testing:
if( MFMailComposeViewController.canSendMail() ) {
let mailComposer = MFMailComposeViewController()
mailComposer.mailComposeDelegate = self
mailComposer.modalPresentationStyle = .formSheet
// self.view.viewWithTag(1) returns a UITextView that has the Lorem Ipsum text in it
if let pdf = try? PDFGenerator.generated(by: [self.view.viewWithTag(1)!]) {
mailComposer.addAttachmentData(pdf, mimeType: "application/pdf", fileName: "lorem")
self.presentVC(mailComposer)
}
}
When the above code is run on my phone, I can see an email compose VC pops up. In the email, there is the pdf attachment. After I send it and tried to open the pdf file on my mac however, Preview.app says that it can't open it.
I think I used this pod wrongly. What did I do wrong?
I am writing an app where users can dynamically generates a pdf file and sends it to people using Mail. I used this code for testing:
When the above code is run on my phone, I can see an email compose VC pops up. In the email, there is the pdf attachment. After I send it and tried to open the pdf file on my mac however, Preview.app says that it can't open it.
I think I used this pod wrongly. What did I do wrong?