From 2ee021b64d5f7169e7aa38b668ababfa72f4d839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Mon, 18 Aug 2025 13:26:19 +0200 Subject: [PATCH 1/6] Fix URL Sharing --- ShareExtension/ShareViewController.swift | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift index 5553a68..805c6d0 100644 --- a/ShareExtension/ShareViewController.swift +++ b/ShareExtension/ShareViewController.swift @@ -57,21 +57,22 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { self.zipFolderAndSetUpIcon() } } else { - for attachment in attachments { - if attachment.hasItemConformingToTypeIdentifier(kUTTypeURL as String) { - attachment.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil) { data, _ in - if let urlData = data as? Data, - let url = URL(dataRepresentation: urlData, relativeTo: nil, isAbsolute: false) - { - self.urls.append(url) - } else if let url = data as? NSURL { - self.urls.append(url as URL) - } - - if self.urls.count == attachments.count { - DispatchQueue.main.async { - self.zipFolderAndSetUpIcon() - } + + let filteredAttachments = attachments.filter { $0.hasItemConformingToTypeIdentifier(kUTTypeURL as String) } + + for attachment in filteredAttachments { + attachment.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil) { data, _ in + if let urlData = data as? Data, + let url = URL(dataRepresentation: urlData, relativeTo: nil, isAbsolute: false) + { + self.urls.append(url) + } else if let url = data as? NSURL { + self.urls.append(url as URL) + } + + if self.urls.count == filteredAttachments.count { + DispatchQueue.main.async { + self.zipFolderAndSetUpIcon() } } } From 0df17c1bc7eafbccc287c7f88714b72933ff6e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Mon, 18 Aug 2025 13:33:58 +0200 Subject: [PATCH 2/6] Increase Version Number --- QuickDrop.xcodeproj/project.pbxproj | 8 ++++---- QuickDrop/Localizable.xcstrings | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 3f79729..f512483 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -888,8 +888,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 63; - SHARED_VERSION = 1.12.4; + SHARED_BUILD = 64; + SHARED_VERSION = 1.12.5; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -950,8 +950,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 63; - SHARED_VERSION = 1.12.4; + SHARED_BUILD = 64; + SHARED_VERSION = 1.12.5; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index 1e5ce82..a88b076 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -7157,9 +7157,6 @@ } } } - }, - "Reset UD" : { - }, "SaveFilesLocation" : { "extractionState" : "manual", From 4c95be694f01a5980b9fdb7602a4ceff72de7f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Tue, 19 Aug 2025 10:34:59 +0200 Subject: [PATCH 3/6] Improve logging --- .../Connection/InboundNearbyConnection.swift | 6 ++++-- NearbyShare/Connection/NearbyConnection.swift | 8 +++++--- QuickDrop/AppDelegate.swift | 5 +++-- QuickDrop/Localizable.xcstrings | 3 +++ QuickDrop/Util/ErrorAlertHandler.swift | 13 ++++++++----- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/NearbyShare/Connection/InboundNearbyConnection.swift b/NearbyShare/Connection/InboundNearbyConnection.swift index 9008348..5bcb895 100644 --- a/NearbyShare/Connection/InboundNearbyConnection.swift +++ b/NearbyShare/Connection/InboundNearbyConnection.swift @@ -513,9 +513,11 @@ class InboundNearbyConnection: NearbyConnection { #endif filesToBeReceived[id]!.progress = progress filesToBeReceived[id]!.created = true - - log("[InboundNearbyConnection \(self.id)] Accepted file with size \(file.meta.size)") } + + let totalBytes = filesToBeReceived.values.reduce(0) { $0 + $1.meta.size } + let gigabytes = Double(totalBytes) / 1_000_000_000 + log("[InboundNearbyConnection \(self.id)] Accepted \(filesToBeReceived.count) file(s) with size \(totalBytes) bytes (\(gigabytes) GB)") var frame = Sharing_Nearby_Frame() frame.version = .v1 diff --git a/NearbyShare/Connection/NearbyConnection.swift b/NearbyShare/Connection/NearbyConnection.swift index c3c257b..8194122 100644 --- a/NearbyShare/Connection/NearbyConnection.swift +++ b/NearbyShare/Connection/NearbyConnection.swift @@ -207,8 +207,7 @@ class NearbyConnection { log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:)") if let content = content, !content.isEmpty { - log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), but trying to process the frame anyway. Frame length: \(content.count)") - self.processReceivedFrame(frameData: content) + log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), and frame not empty. Frame length: \(content.count)") } else { log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), but no content received anymore (\(String(describing: content))).") @@ -424,7 +423,10 @@ class NearbyConnection { } else if offlineFrame.hasV1, offlineFrame.v1.hasType, case .keepAlive = offlineFrame.v1.type { - log("[NearbyConnection \(self.id)] Sent keep-alive, \(self.bytesTransferred) bytes sent") + let bytesTransferred = self.bytesTransferred + let gigabytesTransferred = Double(bytesTransferred) / 1_000_000_000 + + log("[NearbyConnection \(self.id)] Sent keep-alive, \(self.bytesTransferred) bytes (\(gigabytesTransferred) GB) sent") sendKeepAlive(ack: true) } else { diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index b9e989f..0c2829a 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -112,6 +112,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele let queue2 = DispatchQueue(label: "NetworkConnectionMonitor") hasConnectionMonitor.start(queue: queue2) + + log("Application did finish launching") } @@ -147,10 +149,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele func application(_ application: NSApplication, open urls: [URL]) { for url in urls { if url.scheme == "quickdrop", url.host == "sendLog" { - sendLoggingString() // this time it runs in the main app + sendLoggingString() } - if url.scheme == "quickdrop", url.host == "openLog", let url = LogManager.sharedInstance.logFileURL { log("Opening log file: \(url)") // open folder containing the log file diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index a88b076..1e5ce82 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -7157,6 +7157,9 @@ } } } + }, + "Reset UD" : { + }, "SaveFilesLocation" : { "extractionState" : "manual", diff --git a/QuickDrop/Util/ErrorAlertHandler.swift b/QuickDrop/Util/ErrorAlertHandler.swift index 0bd0107..a9a89fe 100644 --- a/QuickDrop/Util/ErrorAlertHandler.swift +++ b/QuickDrop/Util/ErrorAlertHandler.swift @@ -148,12 +148,15 @@ func sendLoggingString() { if let url = LogManager.sharedInstance.logFileURL { let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown" log("Sending logging string with file URL: \(url)") + log("Currently running apps: \(NSWorkspace.shared.runningApplications.map { $0.localizedName ?? "Unknown" })") - sendEmailWithAttachment( - fileURL: url, - recipients: ["quickdrop@leonboettger.com"], - subject: "QuickDrop \(appVersion) - \(getDeviceAndSystem())" - ) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { + sendEmailWithAttachment( + fileURL: url, + recipients: ["quickdrop@leonboettger.com"], + subject: "QuickDrop \(appVersion) - \(getDeviceAndSystem())" + ) + }) } } From e47934a0a8470b2d0648b5430c735cba95a483e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Tue, 19 Aug 2025 10:49:57 +0200 Subject: [PATCH 4/6] Improve logging --- NearbyShare/Util/SaveFilesManager.swift | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/NearbyShare/Util/SaveFilesManager.swift b/NearbyShare/Util/SaveFilesManager.swift index f6239b3..2cee3ce 100644 --- a/NearbyShare/Util/SaveFilesManager.swift +++ b/NearbyShare/Util/SaveFilesManager.swift @@ -30,10 +30,10 @@ public class SaveFilesManager { } if didSomething { - log("Temporary directory cleared.") + log("[SaveFilesManager] Temporary directory cleared.") } } catch { - log("Failed to list contents of temp directory: \(error)") + log("[SaveFilesManager] Failed to list contents of temp directory: \(error)") } } @@ -68,7 +68,7 @@ public class SaveFilesManager { for file in files { if !loggedExecution { - log("Moving pending files to target directory") + log("[SaveFilesManager] Moving pending files to target directory") loggedExecution = true } @@ -76,11 +76,11 @@ public class SaveFilesManager { let destinationURL = target.appendingPathComponent(fileName) if !filesFinishedDownloading.contains(destinationURL) { - log("File \(file) not finished downloading, skipping") + log("[SaveFilesManager] File \(file) not finished downloading, skipping") continue } - log("Moving file: \(file.lastPathComponent) to \(destinationURL.lastPathComponent)") + log("[SaveFilesManager] Moving file: \(file.lastPathComponent) to \(destinationURL.lastPathComponent)") do { try fileManager.copyItem(at: file, to: destinationURL) @@ -104,10 +104,10 @@ public class SaveFilesManager { try fileManager.removeItem(at: file) } catch { - log("Error moving file: \(error)") + log("[SaveFilesManager] Error moving file: \(error)") } } - log("Moved all pending files to target directory") + log("[SaveFilesManager] Moved all pending files to target directory") } catch { // Pending directory doesn't exist or is empty @@ -118,7 +118,7 @@ public class SaveFilesManager { #if os(macOS) if UserDefaults.standard.bool(forKey: UserDefaultsKeys.openFinderAfterReceiving.rawValue) { - log("Opening \(filesFinishedDownloadingSinceLastRun.count) file(s) in Finder.") + log("[SaveFilesManager] Opening \(filesFinishedDownloadingSinceLastRun.count) file(s) in Finder.") NSWorkspace.shared.activateFileViewerSelecting(filesFinishedDownloadingSinceLastRun) } #endif @@ -136,7 +136,7 @@ public class SaveFilesManager { return } - log("Stopping access to security scoped resource: \(url)") + log("[SaveFilesManager] Stopping access to security scoped resource: \(url)") url.stopAccessingSecurityScopedResource() securityScopeUrl = nil } @@ -144,7 +144,7 @@ public class SaveFilesManager { public func getSaveDirectory() -> URL { if let securityScopeUrl = securityScopeUrl { - log("Using existing security scope URL: \(securityScopeUrl)") + log("[SaveFilesManager] Using existing security scope URL: \(securityScopeUrl)") return securityScopeUrl } @@ -158,17 +158,17 @@ public class SaveFilesManager { if !isStale { if url.startAccessingSecurityScopedResource() { - log("Successfully accessed security scoped resource: \(url)") + log("[SaveFilesManager] Successfully accessed security scoped resource: \(url)") securityScopeUrl = url return url } } else { - log("Bookmark is stale, using default downloads folder.") + log("[SaveFilesManager] Bookmark is stale, using default downloads folder.") } } catch { - log("Failed to resolve bookmark: \(error), using default downloads folder.") + log("[SaveFilesManager] Failed to resolve bookmark: \(error), using default downloads folder.") } #endif } @@ -176,7 +176,7 @@ public class SaveFilesManager { do { return try FileManager.default.url(for: .downloadsDirectory, in: .userDomainMask, appropriateFor: nil, create: true).resolvingSymlinksInPath() } catch { - fatalError("Failed to get downloads directory: \(error)") + fatalError("[SaveFilesManager] Failed to get downloads directory: \(error)") } } From c2ef5c329a0714acabf1d2f7b2b6286cab292bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Tue, 19 Aug 2025 11:01:49 +0200 Subject: [PATCH 5/6] Increase version number --- QuickDrop.xcodeproj/project.pbxproj | 8 ++++---- QuickDrop/AppDelegate.swift | 4 +++- QuickDrop/Localizable.xcstrings | 3 --- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index f512483..ca98811 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -888,8 +888,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 64; - SHARED_VERSION = 1.12.5; + SHARED_BUILD = 65; + SHARED_VERSION = 1.12.6; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -950,8 +950,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 64; - SHARED_VERSION = 1.12.5; + SHARED_BUILD = 65; + SHARED_VERSION = 1.12.6; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index 0c2829a..e206a47 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -233,6 +233,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele let plusView = PlusView(closeView: { log("Closing plus screen") self.plusWindow?.close() + self.plusWindow = nil }) // Create an NSWindow to host the SwiftUI view @@ -252,7 +253,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele window.setFrameAutosaveName("PlusScreen") window.contentView = NSHostingView(rootView: plusView) - // Reset reference when closed by red button + // Reset reference when closed by close button NotificationCenter.default.addObserver(forName: NSWindow.willCloseNotification, object: window, queue: .main) { [weak self] _ in self?.plusWindow = nil } @@ -446,6 +447,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele if let plusWindow = plusWindow { log("Closing plus screen because of error") plusWindow.close() + self.plusWindow = nil } ErrorAlertHandler.shared.showErrorAlert(for: activeIncomingTransfers[id]?.device.name ?? "Android", error: error) diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index 1e5ce82..a88b076 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -7157,9 +7157,6 @@ } } } - }, - "Reset UD" : { - }, "SaveFilesLocation" : { "extractionState" : "manual", From 60d44bae72f82c8e16b1dcda8af9f627c1833505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Tue, 19 Aug 2025 11:42:11 +0200 Subject: [PATCH 6/6] Increase build --- QuickDrop.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index ca98811..6aa3af9 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -888,7 +888,7 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 65; + SHARED_BUILD = 66; SHARED_VERSION = 1.12.6; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -950,7 +950,7 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 65; + SHARED_BUILD = 66; SHARED_VERSION = 1.12.6; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES;