From 9e8ff9cfd13ddbafbd373523d9f7d5c8056dbf67 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 4 Jul 2025 17:40:50 +0200 Subject: [PATCH] Remove all debug prints and fix API misuse warnings - Remove [PEERS] and [ANNOUNCE] debug print statements - Fix unused variable warnings in BluetoothMeshService - Add peripheral.state == .connected check before writeValue in announce sending - Remove unused peerInfo and peerNicknamesCopy variables - Fix API MISUSE warnings about sending commands to disconnected peripherals --- bitchat.xcodeproj/project.pbxproj | 21 ++++++++++++++------- bitchat/Services/BluetoothMeshService.swift | 16 +++------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/bitchat.xcodeproj/project.pbxproj b/bitchat.xcodeproj/project.pbxproj index 5567e99e..818cdbe2 100644 --- a/bitchat.xcodeproj/project.pbxproj +++ b/bitchat.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 63; objects = { /* Begin PBXBuildFile section */ @@ -36,7 +36,7 @@ 6DC1563390A15C042D059CF9 /* EncryptionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionService.swift; sourceTree = ""; }; 763E0DBA9492A654FC0CDCB9 /* AppInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfoView.swift; sourceTree = ""; }; 7EEBDA723E1CFD88758DA4AC /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 997D512074C64904D75DDD40 /* bitchat.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 997D512074C64904D75DDD40 /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; A08E03AA0C63E97C91749AEC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; A2136C3E22D02D4A8DBE7EAB /* BinaryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocol.swift; sourceTree = ""; }; D5C3D880FF8AE1673B20E1E3 /* BluetoothMeshService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothMeshService.swift; sourceTree = ""; }; @@ -179,7 +179,6 @@ ); mainGroup = 18198ED912AAF495D8AF7763; minimizedProjectReferenceProxies = 1; - preferredProjectObjectVersion = 54; projectDirPath = ""; projectRoot = ""; targets = ( @@ -253,6 +252,7 @@ CODE_SIGNING_REQUIRED = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = L3N5LHJD5Y; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = bitchat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -264,9 +264,12 @@ PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_NAME = bitchat; SDKROOT = iphoneos; - SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; @@ -279,6 +282,7 @@ CODE_SIGNING_REQUIRED = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = L3N5LHJD5Y; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = bitchat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -290,9 +294,12 @@ PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_NAME = bitchat; SDKROOT = iphoneos; - SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; diff --git a/bitchat/Services/BluetoothMeshService.swift b/bitchat/Services/BluetoothMeshService.swift index e3b2c2ca..ad56619e 100644 --- a/bitchat/Services/BluetoothMeshService.swift +++ b/bitchat/Services/BluetoothMeshService.swift @@ -779,17 +779,6 @@ class BluetoothMeshService: NSObject { peerID != myPeerID } - // Get nicknames for logging - peerNicknamesLock.lock() - let peerNicknamesCopy = peerNicknames - peerNicknamesLock.unlock() - - let peerInfo = validPeers.map { peerID in - let nickname = peerNicknamesCopy[peerID] ?? "unknown" - return "\(peerID):\(nickname)" - } - - print("[PEERS] Active peers: \(peerInfo.joined(separator: ", "))") return Array(validPeers).sorted() } @@ -849,7 +838,7 @@ class BluetoothMeshService: NSObject { processedKeyExchanges = processedKeyExchanges.filter { !$0.contains(peerID) } peerNicknamesLock.lock() - let nickname = peerNicknames[peerID] + _ = peerNicknames[peerID] peerNicknames.removeValue(forKey: peerID) peerNicknamesLock.unlock() @@ -1524,7 +1513,7 @@ class BluetoothMeshService: NSObject { let wasInserted = activePeers.insert(senderID).inserted activePeersLock.unlock() if wasInserted { - print("[ANNOUNCE] Added peer \(senderID) (\(nickname)) to active peers") + // Added peer \(senderID) (\(nickname)) to active peers } // Show join message only for first announce @@ -2031,6 +2020,7 @@ extension BluetoothMeshService: CBPeripheralDelegate { DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self, weak peripheral] in guard let self = self, let peripheral = peripheral, + peripheral.state == .connected, let characteristic = peripheral.services?.first(where: { $0.uuid == BluetoothMeshService.serviceUUID })?.characteristics?.first(where: { $0.uuid == BluetoothMeshService.characteristicUUID }) else { return } let announcePacket = BitchatPacket(