We are developing a new App for the iPad (iOS). The new App needs to access the Buletooth device. We expect to use CoreBluetooth framework to realize it. However, the state of the CBCentralManager instance is always Unsupported. Why? How to solve it?
We develop the App on the MaxBook Pro OS X EI Captan V10.11.4. The version of Xcode is V7.3.1.
The followings are the codes.
class BluetoothService: NSObject, CBCentralManagerDelegate
{
var centralMgr: CBCentralManager?
func initializeCenral(){
centralMgr = CBCentralManager(delegate: self, queue: nil)
}
@objc func centralManagerDidUpdateState(central: CBCentralManager){
switch central.state{
case CBCentralManagerState.PowerOff:
print("Power Off")
case CBCentralManagerState.PowerOn:
print("Power On")
case CBCentralManagerState.Resetting:
print("Resetting")
case CBCentralManagerState.Unsupported:
print("Unsupported") // always at this state
default: break
}
}
//...
}//#
<== I created a new project for Command Line tool, and let it run the same codes on the local MacBook. In this case, the state of CBCentralManager becomes to PowerOn. It means that the CoreBluetooth Cannot run on any simulators.