Sidney Liu
Sidney Liu

Reputation: 477

Simplest implementation log share button in SwiftUI?

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.

Upvotes: 0

Views: 49

Answers (0)

Related Questions