macOS (2017 iMac)에서 블루투스 주변 장치에 액세스하려고 시도했지만 CBCentralManager
은 .poweredOn
상태로 절대 입력되지 않습니다.macOS CBCentralManager 상태가 지원되지 않음
import Cocoa
import CoreBluetooth
class BluetoothManager: NSObject {
var centralManager: CBCentralManager!
override init() {
super.init()
self.centralManager = CBCentralManager(delegate: self, queue:nil)
self.checkState()
}
func checkState() {
print("central state: \(self.centralManager?.state.rawValue ?? -1)")
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(2), execute: {
self.checkState()
})
}
}
extension BluetoothManager: CBCentralManagerDelegate {
func centralManagerDidUpdateState(_ central: CBCentralManager) {
switch central.state {
case .poweredOn:
print("Power on")
case .unsupported:
print("Unsupported")
default:break
}
}
}
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var bluetoothManager: BluetoothManager?
func applicationDidFinishLaunching(_ aNotification: Notification) {
self.bluetoothManager = BluetoothManager()
}
...
}
이 것입니다 경고 콘솔, Unsupported
지속적으로 출력
[CoreBluetooth] XPC connection invalid
나는 그 iOS 기기 그냥 생각하지만 내가, 내가 시도 Info.plist
키 NSBluetoothPeripheralUsageDescription
, 알고있다.
iMac에서 블루투스를 관리하는 데 잘못된 방향을 찾고 있습니까? 아니면 구현에 뭔가 빠졌습니까? 나는 Core Bluetooth documentation에서 요구되는 모든 것을 다 다루었다고 느낀다.