CoreBluetooth didDiscoverPeripheral不在Swift中调用

我99%确定我按照说明正确设置CoreBluetooth 。 无论我做什么,当我在iPad mini上运行这个应用程序时,蓝牙都在说。 这是说它正在扫描设备,但它绝对没有find任何设备。 如果我去设备上的蓝牙菜单,我看到其他设备被发现。 我初始化CBCentralManager 。 我设置了centralManagerDidUpdateState 。 当确定蓝牙准备就绪时,它会调用centralManager.scanForPeripheralsWithServices 。 所有这一切都正确地发生。 但是我的centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!)functioncentralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!)永远不会被调用。 我的代码非常简单。 也许我错过了一些东西,但我能够确认我的Macbook是BTLE设备,而我的iPad mini也是BTLE设备。 这是我的代码。

 import UIKit import CoreBluetooth class ViewController: UIViewController, CBCentralManagerDelegate { var centralManager:CBCentralManager! var blueToothReady = false override func viewDidLoad() { super.viewDidLoad() startUpCentralManager() } func startUpCentralManager() { println("Initializing central manager") centralManager = CBCentralManager(delegate: self, queue: nil) } func discoverDevices() { println("discovering devices") centralManager.scanForPeripheralsWithServices(nil, options: nil) } func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) { println("Discovered \(peripheral.name)") } func centralManagerDidUpdateState(central: CBCentralManager!) { println("checking state") switch (central.state) { case .PoweredOff: println("CoreBluetooth BLE hardware is powered off") case .PoweredOn: println("CoreBluetooth BLE hardware is powered on and ready") blueToothReady = true; case .Resetting: println("CoreBluetooth BLE hardware is resetting") case .Unauthorized: println("CoreBluetooth BLE state is unauthorized") case .Unknown: println("CoreBluetooth BLE state is unknown"); case .Unsupported: println("CoreBluetooth BLE hardware is unsupported on this platform"); } if blueToothReady { discoverDevices() } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 

我必须得到我的MacBook广告。 一旦我使用https://github.com/mttrb/BeaconOSX这样做,它就像我写的一样。