From 088a3b538917dd9b6ca5f80f2dd96a516d2778ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Mon, 5 May 2025 09:49:46 +0200 Subject: [PATCH] Send file as log --- NearDrop/TutorialView.swift | 24 +++++++++++++++++++----- QuickDrop.xcodeproj/project.pbxproj | 8 ++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/NearDrop/TutorialView.swift b/NearDrop/TutorialView.swift index ddf56f5..bcff9f9 100644 --- a/NearDrop/TutorialView.swift +++ b/NearDrop/TutorialView.swift @@ -110,11 +110,13 @@ struct LargeAppIconView: View { .padding(.top, 50) .onTapGesture { taps += 1 - print("Tapped \(taps) times") + print("Clicked \(taps) times") if taps == 5 { sendLoggingString() print("Copied log to clipboard") + + taps = 0 } } @@ -132,16 +134,28 @@ struct LargeAppIconView: View { func sendLoggingString() { - let logString = LogManager.sharedInstance.getLogString() - - if let url = URL(string: "mailto:quickdrop@leonboettger.com?subject=QuickDrop Log&body=\n\n\n––––––––––––––––––––\n\(logString)") { - NSWorkspace.shared.open(url) + if let url = LogManager.sharedInstance.logFileURL { + sendEmailWithAttachment(fileURL: url, recipients: ["quickdrop@leonboettger.com"], subject: "QuickDrop Log") } + let logString = LogManager.sharedInstance.getLogString() + copyToClipboard(logString) } +func sendEmailWithAttachment(fileURL: URL, recipients: [String], subject: String) { + guard let emailService = NSSharingService(named: .composeEmail) else { + print("No email service available") + return + } + + emailService.recipients = recipients + emailService.subject = subject + emailService.perform(withItems: [fileURL]) +} + + func copyToClipboard(_ text: String) { let pasteboard = NSPasteboard.general pasteboard.clearContents() diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 8a5858f..1a69ada 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -789,8 +789,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 30; - SHARED_VERSION = 1.7.2; + SHARED_BUILD = 31; + SHARED_VERSION = 1.7.3; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; @@ -848,8 +848,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 30; - SHARED_VERSION = 1.7.2; + SHARED_BUILD = 31; + SHARED_VERSION = 1.7.3; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; };