I want to implement a log exporter to export user logs from pages like Settings or Mail. In UIKit, UIActivityViewController would work well, but I’m looking for a more modern approach using SwiftUI.
I tried using Transferable with ShareLink:
struct ScreenshotFeedbackExporter: Transferable {
var screenshots: [UIImage] = []
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(exportedContentType: .zip) { exporter in
let url = try exporter.fileURL()
return SentTransferredFile(url)
}
.suggestedFileName("feedback.zip")
}
func fileURL() throws -> URL {
try FeedbackManager.shared.constructShareFile(screenshots: screenshots)
}
}
However, when sharing the file on platforms like Telegram, it doesn’t open correctly.
constructShareFile(screenshots:)returns a real url and includes real hundreds KB zip file which is not just named "file"