mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 22:45:19 +00:00
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:
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 63;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -36,7 +36,7 @@
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
@@ -179,6 +179,7 @@
|
||||
);
|
||||
mainGroup = 18198ED912AAF495D8AF7763;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
preferredProjectObjectVersion = 54;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
@@ -252,11 +253,8 @@
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -266,12 +264,9 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
|
||||
PRODUCT_NAME = bitchat;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -284,11 +279,8 @@
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -298,12 +290,9 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
|
||||
PRODUCT_NAME = bitchat;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -324,7 +313,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bitchat.app;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
|
||||
PRODUCT_NAME = bitchat;
|
||||
SDKROOT = macosx;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
@@ -407,7 +396,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bitchat.app;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
|
||||
PRODUCT_NAME = bitchat;
|
||||
SDKROOT = macosx;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
|
||||
@@ -40,12 +40,5 @@
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -88,10 +88,6 @@ class BluetoothMeshService: NSObject {
|
||||
private var peerListUpdateTimer: Timer?
|
||||
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
|
||||
private var coverTrafficTimer: Timer?
|
||||
private let coverTrafficPrefix = "☂DUMMY☂" // Prefix to identify dummy messages after decryption
|
||||
@@ -850,7 +846,7 @@ class BluetoothMeshService: NSObject {
|
||||
peerRSSI.removeValue(forKey: peerID)
|
||||
announcedPeers.remove(peerID)
|
||||
announcedToPeers.remove(peerID)
|
||||
processedKeyExchanges.removeAll { $0.contains(peerID) }
|
||||
processedKeyExchanges = processedKeyExchanges.filter { !$0.contains(peerID) }
|
||||
|
||||
peerNicknamesLock.lock()
|
||||
let nickname = peerNicknames[peerID]
|
||||
@@ -1504,7 +1500,7 @@ class BluetoothMeshService: NSObject {
|
||||
peerLastSeenTimestamps.removeValue(forKey: stalePeerID)
|
||||
|
||||
// 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
|
||||
@@ -2393,68 +2389,6 @@ extension BluetoothMeshService: CBPeripheralManagerDelegate {
|
||||
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) {
|
||||
peerLastSeenTimestamps[peerID] = Date()
|
||||
|
||||
@@ -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 UserNotifications
|
||||
#if os(iOS)
|
||||
@@ -12,11 +20,9 @@ class NotificationService {
|
||||
private init() {}
|
||||
|
||||
func requestAuthorization() {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
|
||||
if granted {
|
||||
// Permission granted
|
||||
} else if let error = error {
|
||||
// print("[NOTIFICATIONS] Permission error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,12 +55,8 @@ class NotificationService {
|
||||
trigger: nil // Deliver immediately
|
||||
)
|
||||
|
||||
UNUserNotificationCenter.current().add(request) { error in
|
||||
if let error = error {
|
||||
// print("[NOTIFICATIONS] Error sending notification: \(error)")
|
||||
} else {
|
||||
// Notification sent
|
||||
}
|
||||
UNUserNotificationCenter.current().add(request) { _ in
|
||||
// Notification added
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
name: bitchat
|
||||
options:
|
||||
bundleIdPrefix: com.bitchat
|
||||
bundleIdPrefix: chat.bitchat
|
||||
deploymentTarget:
|
||||
iOS: 16.0
|
||||
macOS: 13.0
|
||||
|
||||
Reference in New Issue
Block a user