Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion companion/TouchBridge/Core/CompanionCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ public final class CompanionCoordinator: NSObject, @unchecked Sendable {
pendingPairingToken = token
pendingMacName = macName
bleClient.serviceUUID = serviceUUID
startScanning()
// A prior pairing attempt (e.g. with stale/expired data) may have left
// BLEClient mid-scan or mid-connect for a *different* service UUID.
// startScanning() alone is a no-op while isScanning is already true,
// so the old UUID would keep being scanned forever. Force a clean
// stop + reset before scanning for the new one.
bleClient.resetConnectionAndScan()
logger.info("Pairing session started for \(macName)")
}

Expand Down
25 changes: 25 additions & 0 deletions daemon/Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// swift-tools-version: 5.9

import PackageDescription
import Foundation

// Resolves to the directory containing this Package.swift, regardless of the
// working directory `swift build` is invoked from — needed for the
// -sectcreate __info_plist linker flags below.
let packageDir = URL(fileURLWithPath: #filePath).deletingLastPathComponent().path

let package = Package(
name: "TouchBridgeDaemon",
Expand Down Expand Up @@ -29,13 +35,32 @@ let package = Package(
dependencies: [
"TouchBridgeCore",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
linkerSettings: [
// Embeds an Info.plist so CoreBluetooth can find
// NSBluetoothAlwaysUsageDescription — without it macOS silently
// denies Bluetooth authorization for plain SwiftPM executables.
.unsafeFlags([
"-Xlinker", "-sectcreate",
"-Xlinker", "__TEXT",
"-Xlinker", "__info_plist",
"-Xlinker", "\(packageDir)/Sources/touchbridged/Supporting/Info.plist",
])
]
),
.executableTarget(
name: "touchbridge-test",
dependencies: [
"TouchBridgeCore",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
linkerSettings: [
.unsafeFlags([
"-Xlinker", "-sectcreate",
"-Xlinker", "__TEXT",
"-Xlinker", "__info_plist",
"-Xlinker", "\(packageDir)/Sources/touchbridge-test/Supporting/Info.plist",
])
]
),
.executableTarget(
Expand Down
22 changes: 22 additions & 0 deletions daemon/Sources/touchbridge-test/Supporting/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>dev.touchbridge.test</string>
<key>CFBundleName</key>
<string>touchbridge-test</string>
<key>CFBundleExecutable</key>
<string>touchbridge-test</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>TouchBridge uses Bluetooth to communicate with your paired iPhone, Apple Watch, or Android device for biometric authentication.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>TouchBridge uses Bluetooth to communicate with your paired iPhone, Apple Watch, or Android device for biometric authentication.</string>
</dict>
</plist>
22 changes: 22 additions & 0 deletions daemon/Sources/touchbridged/Supporting/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>dev.touchbridge.daemon</string>
<key>CFBundleName</key>
<string>touchbridged</string>
<key>CFBundleExecutable</key>
<string>touchbridged</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>TouchBridge uses Bluetooth to communicate with your paired iPhone, Apple Watch, or Android device for biometric authentication.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>TouchBridge uses Bluetooth to communicate with your paired iPhone, Apple Watch, or Android device for biometric authentication.</string>
</dict>
</plist>
5 changes: 5 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ info "Installing daemon binary..."
mkdir -p "$(dirname "$DAEMON_BIN")"
cp "$DAEMON_BUILD" "$DAEMON_BIN"
chmod 755 "$DAEMON_BIN"
# Re-sign after copy: the linker's own ad-hoc "linker-signed" signature
# (produced because the build embeds an Info.plist via -sectcreate for
# NSBluetoothAlwaysUsageDescription) is rejected as "Code Signature Invalid"
# on some macOS/Xcode versions. A plain ad-hoc `codesign` pass fixes this.
codesign --force -s - "$DAEMON_BIN" 2>/dev/null || true
info "Installed $DAEMON_BIN"

info "Installing PAM module..."
Expand Down