EAAccessoryManager showBluetoothAccessoryPickerWithNameFilter crashes

Originator:Atrinax
Number:rdar://29155887 Date Originated:8 Nov 2016
Status:Open Resolved:No
Product:iOS Product Version:10.0.1
Classification:iPod Accessory Protocol (iAP) Reproducible:Yes
 
When bluetooth is disabled, app crashes when calling EAAccessoryManager.shared().showBluetoothAccessoryPicker(withNameFilter: nil, completion: { error in
        print(error?.localizedDescription)
      }) 
for the second time.

Steps to Reproduce:
1. Disable bluetooth in settings
2. Call EAAccessoryManager.shared().showBluetoothAccessoryPicker
3. Click OK
4. Call EAAccessoryManager.shared().showBluetoothAccessoryPicker anytime again in the app
5. Observe crash

Comments

Possible solution

Here is how I deal with the issue for a time being:

import ExternalAccessory
import CoreBluetooth

let btManager = CBCentralManager()

func pair() {
    if btManager.state == .poweredOn {
        EAAccessoryManager.shared()
            .showBluetoothAccessoryPicker(withNameFilter: nil)
    }
}

This will display a prompt to enable bluetooth or show a picker if the bluetooth is enabled.

Thread with similar problem: http://stackoverflow.com/questions/39509272/eaaccessorymanager-showbluetoothaccessorypickerwithnamefilter-crashes-on-ios-10

Another radar: rdar://27689885 (not publicly available)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!