From 608ab41c0bda29755f93468744bd44accf7e6bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sun, 17 Aug 2025 10:35:34 +0200 Subject: [PATCH] Fix iOS compiling --- NearbyShare/Connection/NearbyConnectionManager.swift | 12 ++++++------ NearbyShare/Model/DataModel.swift | 4 ++-- QuickDrop/AppDelegate.swift | 2 +- QuickDropiOS/ReceiveModel.swift | 2 +- QuickDropiOS/ShareViewModel.swift | 3 +-- ShareExtension/ShareViewController.swift | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/NearbyShare/Connection/NearbyConnectionManager.swift b/NearbyShare/Connection/NearbyConnectionManager.swift index 69a4b41..15edd10 100644 --- a/NearbyShare/Connection/NearbyConnectionManager.swift +++ b/NearbyShare/Connection/NearbyConnectionManager.swift @@ -22,7 +22,7 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb private var mdnsServices: [NetService] = [] private var incomingConnections: [String: InboundNearbyConnection] = [:] private var foundServices: [String: FoundServiceInfo] = [:] - private var shareExtensionDelegates: [ShareExtensionDelegate] = [] + private var shareExtensionDelegates: [OutboundAppDelegate] = [] private var outgoingTransfers: [String: OutgoingTransferInfo] = [:] private var startedDeviceDiscovery = false private var browsers: [NWBrowser] = [] @@ -32,7 +32,7 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb private var qrCodeNameEncryptionKey: SymmetricKey? public let endpointID: [UInt8] = generateEndpointID() - public var mainAppDelegate: (any MainAppDelegate)? + public var mainAppDelegate: (any InboundAppDelegate)? public static let shared = NearbyConnectionManager() @@ -193,7 +193,7 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb } - public func addShareExtensionDelegate(_ delegate: ShareExtensionDelegate) { + public func addShareExtensionDelegate(_ delegate: OutboundAppDelegate) { shareExtensionDelegates.append(delegate) for service in foundServices.values { guard let device = service.device else { continue } @@ -202,7 +202,7 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb } - public func removeShareExtensionDelegate(_ delegate: ShareExtensionDelegate) { + public func removeShareExtensionDelegate(_ delegate: OutboundAppDelegate) { shareExtensionDelegates.removeAll(where: { $0 === delegate }) } @@ -315,7 +315,7 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb } - public func startOutgoingTransfer(deviceID: String, delegate: ShareExtensionDelegate, urls: [URL], textToSend: String?) { + public func startOutgoingTransfer(deviceID: String, delegate: OutboundAppDelegate, urls: [URL], textToSend: String?) { log("Starting outgoing transfer to \(deviceID)") guard let info = foundServices[deviceID] else { return } @@ -448,6 +448,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb let service: NWBrowser.Result let device: RemoteDeviceInfo let connection: OutboundNearbyConnection - let delegate: ShareExtensionDelegate + let delegate: OutboundAppDelegate } } diff --git a/NearbyShare/Model/DataModel.swift b/NearbyShare/Model/DataModel.swift index afba53f..7aad1cd 100644 --- a/NearbyShare/Model/DataModel.swift +++ b/NearbyShare/Model/DataModel.swift @@ -26,13 +26,13 @@ protocol OutboundNearbyConnectionDelegate { } -public protocol MainAppDelegate { +public protocol InboundAppDelegate: AnyObject { func obtainUserConsent(for transfer: TransferMetadata, from device: RemoteDeviceInfo) func connectionWasTerminated(from device: RemoteDeviceInfo, wasPlainTextTransfer: Bool, error: Error?) } -public protocol ShareExtensionDelegate: AnyObject { +public protocol OutboundAppDelegate: AnyObject { func addDevice(device: RemoteDeviceInfo) func removeDevice(id: String) func startTransferWithQrCode(device: RemoteDeviceInfo) diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index 91e562c..30ed0b3 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -14,7 +14,7 @@ import SwiftUI import UserNotifications @main -class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate, NSWindowDelegate, MainAppDelegate { +class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate, NSWindowDelegate, InboundAppDelegate { private var statusItem: NSStatusItem? diff --git a/QuickDropiOS/ReceiveModel.swift b/QuickDropiOS/ReceiveModel.swift index 2a2a1a3..9232613 100644 --- a/QuickDropiOS/ReceiveModel.swift +++ b/QuickDropiOS/ReceiveModel.swift @@ -7,7 +7,7 @@ import SwiftUI -class ReceiveModel: ObservableObject, MainAppDelegate { +class ReceiveModel: ObservableObject, InboundAppDelegate { init() { diff --git a/QuickDropiOS/ShareViewModel.swift b/QuickDropiOS/ShareViewModel.swift index 101e980..9ea0f0d 100644 --- a/QuickDropiOS/ShareViewModel.swift +++ b/QuickDropiOS/ShareViewModel.swift @@ -7,7 +7,7 @@ import SwiftUI -class ShareViewModel: ObservableObject, ShareExtensionDelegate { +class ShareViewModel: ObservableObject, OutboundAppDelegate { @Published var foundDevices: [RemoteDeviceInfo] = [] @Published var selectedDevice: RemoteDeviceInfo? @@ -17,7 +17,6 @@ class ShareViewModel: ObservableObject, ShareExtensionDelegate { var urls: [URL] = [] var textToSend: String? = nil - //private var errorAlertHandler = ErrorAlertHandler.shared private var connectionEstablished = false private var timeoutDispatchWorkItem: DispatchWorkItem? = nil diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift index 0e7a5df..9dc32a7 100644 --- a/ShareExtension/ShareViewController.swift +++ b/ShareExtension/ShareViewController.swift @@ -10,7 +10,7 @@ import Foundation import SwiftUI import QRCode -class ShareViewController: NSViewController, ShareExtensionDelegate { +class ShareViewController: NSViewController, OutboundAppDelegate { private var urls: [URL] = [] private var textToSend: String? = nil