Repository navigation
Conversation
…g scan
On recent macOS (verified on 27 "Golden Gate"), plain SwiftPM executables
built without an embedded Info.plist have CoreBluetooth silently deny
authorization ("Bluetooth powered off" from BLEServer, or the peripheral
manager never reaching .poweredOn at all in touchbridge-test), because
there's nowhere for NSBluetoothAlwaysUsageDescription to live.
- daemon/Package.swift, Sources/{touchbridged,touchbridge-test}/Supporting/Info.plist:
Embed a minimal Info.plist into both executables via `-sectcreate __TEXT
__info_plist` linker flags, so CoreBluetooth can find the required usage
description and macOS actually prompts for/grants Bluetooth access.
- scripts/install.sh:
Re-sign the installed daemon binary with `codesign --force -s -` after
copying it. The linker's own ad-hoc "linker-signed" signature (a side
effect of the sectcreate flag above) is rejected as "Code Signature
Invalid" (SIGKILL) on some macOS versions; a plain ad-hoc codesign pass
after install fixes this reliably.
- companion/TouchBridge/Core/CompanionCoordinator.swift:
beginPairing() now calls bleClient.resetConnectionAndScan() instead of
startScanning(). If a previous pairing attempt used stale/expired data,
BLEClient is left mid-scan (or mid-connect) for the *old* service UUID.
startScanning() no-ops while already scanning, so entering fresh, valid
pairing data afterward never actually restarted the scan — the app would
show "Scanning for Mac..." indefinitely even with a correct token.
All 112 existing daemon tests pass unchanged.
Verified end-to-end on a real Mac + iPhone: build, install, pair, and
`sudo` authentication via Face ID all working after these fixes.
|
Thanks @yachoukh — all three findings are real and were reproduced on a I rebased the Mac-side parts onto Notes for review:
|
… after install Plain SwiftPM executables have no Info.plist, so CoreBluetooth cannot read NSBluetoothAlwaysUsageDescription. On macOS 27 this leaves TCC authorization incomplete: touchbridged logs 'Bluetooth powered off' and touchbridge-test never receives a poweredOn callback, silently stalling pairing. Embed a minimal Info.plist into the touchbridged and touchbridge-test executables via -sectcreate __TEXT __info_plist. Because the linker-signed signature of such a binary can be rejected after being copied, install.sh now runs an ad-hoc codesign pass on the installed daemon. Mac side of PR #37 by @yachoukh; adapted to v2.0.0 (the companion-side resetConnectionAndScan change is already covered by beginPairing -> unpair, which stops scanning before a new service UUID is used).
|
Thank you @yachoukh. This was the first diagnosis of the macOS 27 Bluetooth problem. #41 carries your Info.plist and re-signing fixes forward, rebased onto v2.0.0 with credit to you, and is now merged. The |
Summary
Found and fixed while setting up TouchBridge from source on macOS 27 ("Golden Gate"). Two of these are very likely macOS-version-specific (recent CoreBluetooth/codesign enforcement changes); the third is a pre-existing logic bug independent of macOS version.
1. Missing Bluetooth entitlement on
touchbridged/touchbridge-testPlain SwiftPM executables built without an embedded
Info.plisthave nowhere forNSBluetoothAlwaysUsageDescriptionto live. On this macOS version, that caused two different symptoms:touchbridged:BLEServerloggedBluetooth powered offimmediately.touchbridge-test pair:CBPeripheralManagernever called back with.poweredOnat all (not even.unauthorized) — the process would sit silently forever, with the phone stuck on "Scanning for Mac...".Fix: embed a minimal
Info.plist(withNSBluetoothAlwaysUsageDescription/NSBluetoothPeripheralUsageDescription) into both executables via-sectcreate __TEXT __info_plistlinker flags indaemon/Package.swift.2. Invalid code signature after adding the Info.plist linker flag
Once the daemon is re-linked with the
-sectcreateflag above, its own ad-hoc "linker-signed" signature is rejected asCode Signature Invalid(hardSIGKILL) after being copied to/usr/local/bin— reproducible via crash reporttermination: CODESIGNING / Invalid Page.Fix:
scripts/install.shnow re-signs the installed binary with a plaincodesign --force -s -pass after copying it, which reliably resolves this.3.
beginPairingdoesn't restart a stuck BLE scanIf a previous pairing attempt used stale/expired pairing data,
BLEClientis left mid-scan (or mid-connect) for the old service UUID.startScanning()no-ops whileisScanningis alreadytrue, so entering fresh, valid pairing data afterward never actually restarted the scan — the app would show "Scanning for Mac..." indefinitely even with a correct, unexpired token.Fix:
CompanionCoordinator.beginPairing()now calls the existingbleClient.resetConnectionAndScan()instead ofstartScanning(), forcing a clean stop + reset before scanning for the new UUID.Testing
daemontests pass unchanged (swift test).scripts/install.sh, paired a real iPhone viatouchbridge-test pair, and ransudo echo test— authenticated successfully via Face ID.Scope note
I found a couple of other things while debugging (a stale bundle identifier conflict under my own free Apple Developer account, and a placeholder-only
AppIcon.appiconset) but those are specific to my local signing setup / cosmetic, not upstream bugs, so I've deliberately left them out of this PR to keep it focused on the actual functional fixes.