Fix compilation errors and prepare for App Store submission

- Fix NotificationService warnings by replacing unused error parameters with _
- Add public domain header to NotificationService.swift
- Fix BluetoothMeshService compilation errors:
  - Replace removeAll with filter for processedKeyExchanges cleanup
  - Remove duplicate cleanupStalePeers function declaration
  - Remove duplicate peerLastSeenTimestamps property declaration
- All code now compiles cleanly for both iOS and macOS targets
This commit is contained in:
jack
2025-07-04 17:28:36 +02:00
parent 44d97ffb7e
commit cbcfaed7a2
5 changed files with 23 additions and 105 deletions
+9 -20
View File
@@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 63; objectVersion = 54;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@@ -36,7 +36,7 @@
6DC1563390A15C042D059CF9 /* EncryptionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionService.swift; sourceTree = "<group>"; }; 6DC1563390A15C042D059CF9 /* EncryptionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionService.swift; sourceTree = "<group>"; };
763E0DBA9492A654FC0CDCB9 /* AppInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfoView.swift; sourceTree = "<group>"; }; 763E0DBA9492A654FC0CDCB9 /* AppInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfoView.swift; sourceTree = "<group>"; };
7EEBDA723E1CFD88758DA4AC /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7EEBDA723E1CFD88758DA4AC /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
997D512074C64904D75DDD40 /* 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; };
A08E03AA0C63E97C91749AEC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; A08E03AA0C63E97C91749AEC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
A2136C3E22D02D4A8DBE7EAB /* BinaryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocol.swift; sourceTree = "<group>"; }; A2136C3E22D02D4A8DBE7EAB /* BinaryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocol.swift; sourceTree = "<group>"; };
D5C3D880FF8AE1673B20E1E3 /* BluetoothMeshService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothMeshService.swift; sourceTree = "<group>"; }; D5C3D880FF8AE1673B20E1E3 /* BluetoothMeshService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothMeshService.swift; sourceTree = "<group>"; };
@@ -179,6 +179,7 @@
); );
mainGroup = 18198ED912AAF495D8AF7763; mainGroup = 18198ED912AAF495D8AF7763;
minimizedProjectReferenceProxies = 1; minimizedProjectReferenceProxies = 1;
preferredProjectObjectVersion = 54;
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";
targets = ( targets = (
@@ -252,11 +253,8 @@
CODE_SIGNING_REQUIRED = YES; CODE_SIGNING_REQUIRED = YES;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = L3N5LHJD5Y;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = bitchat/Info.plist; INFOPLIST_FILE = bitchat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
IPHONEOS_DEPLOYMENT_TARGET = 16.0; IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@@ -266,12 +264,9 @@
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
PRODUCT_NAME = bitchat; PRODUCT_NAME = bitchat;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Debug; name = Debug;
}; };
@@ -284,11 +279,8 @@
CODE_SIGNING_REQUIRED = YES; CODE_SIGNING_REQUIRED = YES;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = L3N5LHJD5Y;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = bitchat/Info.plist; INFOPLIST_FILE = bitchat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
IPHONEOS_DEPLOYMENT_TARGET = 16.0; IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@@ -298,12 +290,9 @@
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
PRODUCT_NAME = bitchat; PRODUCT_NAME = bitchat;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Release; name = Release;
}; };
@@ -324,7 +313,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.bitchat.app; PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
PRODUCT_NAME = bitchat; PRODUCT_NAME = bitchat;
SDKROOT = macosx; SDKROOT = macosx;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
@@ -407,7 +396,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.bitchat.app; PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
PRODUCT_NAME = bitchat; PRODUCT_NAME = bitchat;
SDKROOT = macosx; SDKROOT = macosx;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
-7
View File
@@ -40,12 +40,5 @@
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict> </dict>
</plist> </plist>
+2 -68
View File
@@ -88,10 +88,6 @@ class BluetoothMeshService: NSObject {
private var peerListUpdateTimer: Timer? private var peerListUpdateTimer: Timer?
private let peerListUpdateDebounceInterval: TimeInterval = 0.1 // 100ms debounce for more responsive updates private let peerListUpdateDebounceInterval: TimeInterval = 0.1 // 100ms debounce for more responsive updates
// Stale peer cleanup
private var stalePeerCleanupTimer: Timer?
private var peerLastSeenTimestamps: [String: Date] = [:] // Track when we last saw each peer
// Cover traffic for privacy // Cover traffic for privacy
private var coverTrafficTimer: Timer? private var coverTrafficTimer: Timer?
private let coverTrafficPrefix = "☂DUMMY☂" // Prefix to identify dummy messages after decryption private let coverTrafficPrefix = "☂DUMMY☂" // Prefix to identify dummy messages after decryption
@@ -850,7 +846,7 @@ class BluetoothMeshService: NSObject {
peerRSSI.removeValue(forKey: peerID) peerRSSI.removeValue(forKey: peerID)
announcedPeers.remove(peerID) announcedPeers.remove(peerID)
announcedToPeers.remove(peerID) announcedToPeers.remove(peerID)
processedKeyExchanges.removeAll { $0.contains(peerID) } processedKeyExchanges = processedKeyExchanges.filter { !$0.contains(peerID) }
peerNicknamesLock.lock() peerNicknamesLock.lock()
let nickname = peerNicknames[peerID] let nickname = peerNicknames[peerID]
@@ -1504,7 +1500,7 @@ class BluetoothMeshService: NSObject {
peerLastSeenTimestamps.removeValue(forKey: stalePeerID) peerLastSeenTimestamps.removeValue(forKey: stalePeerID)
// Remove from processed key exchanges // Remove from processed key exchanges
processedKeyExchanges.removeAll { $0.contains(stalePeerID) } processedKeyExchanges = processedKeyExchanges.filter { !$0.contains(stalePeerID) }
} }
// If we had stale peers, notify the UI immediately // If we had stale peers, notify the UI immediately
@@ -2393,68 +2389,6 @@ extension BluetoothMeshService: CBPeripheralManagerDelegate {
return coverTrafficPrefix + (templates.randomElement() ?? "ok") return coverTrafficPrefix + (templates.randomElement() ?? "ok")
} }
// MARK: - Stale Peer Cleanup
private func cleanupStalePeers() {
let staleThreshold: TimeInterval = 60.0 // Consider peers stale after 60 seconds of no activity
let now = Date()
var peersToRemove: [String] = []
// Check for stale peers
activePeersLock.lock()
for peerID in activePeers {
if let lastSeen = peerLastSeenTimestamps[peerID] {
if now.timeIntervalSince(lastSeen) > staleThreshold {
peersToRemove.append(peerID)
}
} else {
// No timestamp recorded, consider it stale
peersToRemove.append(peerID)
}
}
activePeersLock.unlock()
// Remove stale peers
for peerID in peersToRemove {
print("[CLEANUP] Removing stale peer \(peerID) - last seen: \(peerLastSeenTimestamps[peerID]?.description ?? "never")")
// Remove from all tracking structures
activePeersLock.lock()
activePeers.remove(peerID)
activePeersLock.unlock()
peerNicknamesLock.lock()
let nickname = peerNicknames[peerID]
peerNicknames.removeValue(forKey: peerID)
peerNicknamesLock.unlock()
// Remove from other tracking
announcedPeers.remove(peerID)
announcedToPeers.remove(peerID)
peerRSSI.removeValue(forKey: peerID)
peerLastSeenTimestamps.removeValue(forKey: peerID)
cachedMessagesSentToPeer.remove(peerID)
// Disconnect any associated peripherals
if let peripheral = connectedPeripherals[peerID] {
intentionalDisconnects.insert(peripheral.identifier.uuidString)
centralManager.cancelPeripheralConnection(peripheral)
connectedPeripherals.removeValue(forKey: peerID)
peripheralCharacteristics.removeValue(forKey: peripheral)
}
// Log the cleanup
if let nick = nickname {
print("[CLEANUP] Removed stale peer: \(nick) (\(peerID))")
}
}
// Notify UI if any peers were removed
if !peersToRemove.isEmpty {
notifyPeerListUpdate()
}
}
private func updatePeerLastSeen(_ peerID: String) { private func updatePeerLastSeen(_ peerID: String) {
peerLastSeenTimestamps[peerID] = Date() peerLastSeenTimestamps[peerID] = Date()
+11 -9
View File
@@ -1,3 +1,11 @@
//
// NotificationService.swift
// bitchat
//
// This is free and unencumbered software released into the public domain.
// For more information, see <https://unlicense.org>
//
import Foundation import Foundation
import UserNotifications import UserNotifications
#if os(iOS) #if os(iOS)
@@ -12,11 +20,9 @@ class NotificationService {
private init() {} private init() {}
func requestAuthorization() { func requestAuthorization() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
if granted { if granted {
// Permission granted // Permission granted
} else if let error = error {
// print("[NOTIFICATIONS] Permission error: \(error)")
} }
} }
} }
@@ -49,12 +55,8 @@ class NotificationService {
trigger: nil // Deliver immediately trigger: nil // Deliver immediately
) )
UNUserNotificationCenter.current().add(request) { error in UNUserNotificationCenter.current().add(request) { _ in
if let error = error { // Notification added
// print("[NOTIFICATIONS] Error sending notification: \(error)")
} else {
// Notification sent
}
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
name: bitchat name: bitchat
options: options:
bundleIdPrefix: com.bitchat bundleIdPrefix: chat.bitchat
deploymentTarget: deploymentTarget:
iOS: 16.0 iOS: 16.0
macOS: 13.0 macOS: 13.0