From 167542f0faabfc0036e615c44cf780b517765e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= <49094811+leonboe1@users.noreply.github.com> Date: Mon, 15 Jun 2026 21:59:44 +0200 Subject: [PATCH] Fix macOS 27 share extension --- QuickDrop.xcodeproj/project.pbxproj | 124 +++++++++++------------ QuickDrop/InfoPlist.xcstrings | 2 +- ShareExtension/ShareViewController.swift | 20 +++- ShareExtension/View/DeviceListCell.swift | 13 +++ 4 files changed, 95 insertions(+), 64 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index c07c6c1..6d9243e 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -620,13 +620,6 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - F5F5F63DAC90375051BA9F4E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 699DEB9E2AB0573200115D22 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -705,6 +698,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F5F5F63DAC90375051BA9F4E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -1374,14 +1374,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - BECDC1522AF83179791FA522 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A6D000000000000000000201 /* AndroidAirDropModeDetectorTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 699DEB9D2AB0573200115D22 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1496,6 +1488,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + BECDC1522AF83179791FA522 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A6D000000000000000000201 /* AndroidAirDropModeDetectorTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; EB3B9EFF2EF7150400D6704E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1747,49 +1747,6 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 9A4E1D6A03B4FDA5B2074DF0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 92SDAWLN76; - GENERATE_INFOPLIST_FILE = YES; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - "@loader_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 12.0; - PRODUCT_BUNDLE_IDENTIFIER = com.leonboettger.neardrop.tests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QuickDrop.app/Contents/MacOS/QuickDrop"; - }; - name = Release; - }; - A8C87F63E411A0C639408AC5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 92SDAWLN76; - GENERATE_INFOPLIST_FILE = YES; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - "@loader_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 12.0; - PRODUCT_BUNDLE_IDENTIFIER = com.leonboettger.neardrop.tests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QuickDrop.app/Contents/MacOS/QuickDrop"; - }; - name = Debug; - }; 699DEBAF2AB0573200115D22 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1955,8 +1912,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 151; - SHARED_VERSION = 4.1; + SHARED_BUILD = 152; + SHARED_VERSION = 4.2; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -2018,8 +1975,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 151; - SHARED_VERSION = 4.1; + SHARED_BUILD = 152; + SHARED_VERSION = 4.2; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; @@ -2160,6 +2117,49 @@ }; name = Release; }; + 9A4E1D6A03B4FDA5B2074DF0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 92SDAWLN76; + GENERATE_INFOPLIST_FILE = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 12.0; + PRODUCT_BUNDLE_IDENTIFIER = com.leonboettger.neardrop.tests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QuickDrop.app/Contents/MacOS/QuickDrop"; + }; + name = Release; + }; + A8C87F63E411A0C639408AC5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 92SDAWLN76; + GENERATE_INFOPLIST_FILE = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 12.0; + PRODUCT_BUNDLE_IDENTIFIER = com.leonboettger.neardrop.tests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QuickDrop.app/Contents/MacOS/QuickDrop"; + }; + name = Debug; + }; EB3B9F462EF7150400D6704E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { diff --git a/QuickDrop/InfoPlist.xcstrings b/QuickDrop/InfoPlist.xcstrings index 92d0182..f0883b4 100644 --- a/QuickDrop/InfoPlist.xcstrings +++ b/QuickDrop/InfoPlist.xcstrings @@ -1208,4 +1208,4 @@ } }, "version" : "1.0" -} +} \ No newline at end of file diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift index b7729e4..bc455f1 100644 --- a/ShareExtension/ShareViewController.swift +++ b/ShareExtension/ShareViewController.swift @@ -92,6 +92,9 @@ class ShareViewController: NSViewController, OutboundAppDelegate { flowLayout.minimumLineSpacing = 10 listView!.collectionViewLayout = flowLayout listView!.dataSource = self + listView!.delegate = self + listView!.isSelectable = true + listView!.allowsMultipleSelection = false progressDeviceIconWrap!.wantsLayer = true progressDeviceIconWrap!.layer!.masksToBounds = false @@ -247,6 +250,7 @@ class ShareViewController: NSViewController, OutboundAppDelegate { func selectDevice(device: RemoteDeviceInfo) { + guard chosenDevice == nil else { return } listViewWrapper?.animator().isHidden = true dontSeeDeviceButton?.animator().isHidden = true @@ -392,7 +396,7 @@ extension ShareViewController: NSCollectionViewDataSource { guard let collectionViewItem = item as? DeviceListCell else { return item } - let device = foundDevices[indexPath[1]] + let device = foundDevices[indexPath.item] collectionViewItem.configure( deviceName: getDeviceName(device: device), @@ -417,6 +421,20 @@ extension ShareViewController: NSCollectionViewDataSource { } +extension ShareViewController: NSCollectionViewDelegate { + + func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set) { + guard let indexPath = indexPaths.first else { return } + + let itemIndex = indexPath.item + guard foundDevices.indices.contains(itemIndex) else { return } + + collectionView.deselectItems(at: indexPaths) + selectDevice(device: foundDevices[itemIndex]) + } +} + + fileprivate func openPrivacyAndSecuritySettings() { guard let url = URL(string: "x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension") else { return } NSWorkspace.shared.open(url) diff --git a/ShareExtension/View/DeviceListCell.swift b/ShareExtension/View/DeviceListCell.swift index 3ba52e5..1927a1b 100644 --- a/ShareExtension/View/DeviceListCell.swift +++ b/ShareExtension/View/DeviceListCell.swift @@ -19,6 +19,11 @@ class DeviceListCell: NSCollectionViewItem { btn.action = #selector(onClick) btn.target = self + addClickRecognizer(to: view) + addClickRecognizer(to: textField) + addClickRecognizer(to: imageView) + addClickRecognizer(to: peerMarkerView) + peerMarkerView?.image = NSImage(named: "MenuBarIcon") peerMarkerView?.image?.isTemplate = true peerMarkerView?.contentTintColor = .white @@ -34,4 +39,12 @@ class DeviceListCell: NSCollectionViewItem { imageView?.image = deviceImage peerMarkerView?.isHidden = !showsQuickDropPeerMarker } + + private func addClickRecognizer(to targetView: NSView?) { + guard let targetView else { return } + + let recognizer = NSClickGestureRecognizer(target: self, action: #selector(onClick(_:))) + recognizer.buttonMask = 0x1 + targetView.addGestureRecognizer(recognizer) + } }