EA showBluetoothAccessoryPicker not showing in SwiftUI

I have created a small program that needs to connect to an external accessory. I have been able to do so successfully with UIKit and the EA framework.

The problem I am having is that I have a SwiftUI based app that needs to use the External Accessory but when I call the showBluetoothAccessoryPicker function, the picker window does not show.

What I have tried so far:

I have read that you need to have the app delegate with

var window: UIWin

setup correctly to see the picker window. So I created a class

class AppDelegate: UIApplicationDelegate
{
    var window: UIWindow?
}

I then associated the app delegate with my swiftui "App" struct like this:

@main
struct POC: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    var body: some Scene {
        WindowGroup {
            TabSelectionView()
        }
    }
}

Nevertheless, when I call showBluetoothAccessoryPicker the picker window does not show.

I see the following in the output log:

2021-09-20 13:16:31.804796-0500 POC[2150:1514447] IAPDHasLaunched: kIAPAvailableNotification iapdAvailableState 0 -> 0
2021-09-20 13:16:31.805791-0500 POC[2150:1514447] IAP2DHasLaunched: kIAP2AvailableNotification iap2dAvailableState 0 -> 0
2021-09-20 13:16:31.807219-0500 POC[2150:1514447] -[EAAccessoryManager _initFromSingletonCreationMethod] isRunningOnMac

This log appears correct and matches the output from a working demo app that uses UIKit. It's just that the picker window does not show.

Does anybody know what needs to be done to get the picker window to appear correctly for SwiftUI apps? Is there any SwiftUI examples of connecting to an External Accessory that anybody could point me towards?

Thanks in advance for any help.

Did you have any luck with this? I am developing an iOS 15+ SwiftUI app and want to display the BluetoothAccessoryPicker but it just does not show!

I've tried adding the AppDelegate to my app and try to show the picker using:

try await manager.showBluetoothAccessoryPicker(withNameFilter: nil)

But I get nothing, just these lines in the console log:

2021-10-18 11:47:52.905742+0100 MyApp[18402:2620972] IAPAppRegisterClient: capabilities 0x8030

2021-10-18 11:47:52.906019+0100 MyApp[18402:2620972] IAPAppRegisterClient: __eaClientRegisterediapd 0 -> 1

2021-10-18 11:47:52.906085+0100 MyApp[18402:2620972] IAPAppRegisterClient: __eaClientRegisterediap2d 0 -> 1

2021-10-18 11:47:52.906700+0100 MyApp[18402:2620972] IAPDHasLaunched: kIAPAvailableNotification iapdAvailableState 100 -> 0

2021-10-18 11:47:52.906806+0100 MyApp[18402:2620972] IAPAppRegisterClient: __eaiapdHasClientID 0, IAPDHasLaunched 0

2021-10-18 11:47:52.907168+0100 MyApp[18402:2620972] IAP2DHasLaunched: kIAP2AvailableNotification iap2dAvailableState 100 -> 0

2021-10-18 11:47:52.907238+0100 MyApp[18402:2620972] IAPAppRegisterClient: __eaiap2dHasClientID 0, IAP2DHasLaunched 0

2021-10-18 11:47:52.907416+0100 MyApp[18402:2620972] IAPAppRegisterClient: registerWasSuccessful 0

2021-10-18 11:47:52.907716+0100 MyApp[18402:2620972] -[EAAccessoryManager _initFromSingletonCreationMethod] isRunningOnMac

2021-10-18 11:47:52.910422+0100 MyApp[18402:2620972] IAPAppConnectedAccessories: __eaClientHasCheckedForConnectedAccessories 0 -> 1

2021-10-18 11:47:52.910760+0100 MyApp[18402:2620972] IAPAppConnectedAccessories: IAPDHasLaunched 0, IAP2DHasLaunched 0

2021-10-18 11:47:54.170507+0100 MyApp[18402:2620954] Writing analzed variants.

The very last line only appearing when I try to show the picker.

is this issue fixed now? what is the workaround?

FWIW, broken since iOS13. For details check here.. Feedback reported as FB9856371.

EA showBluetoothAccessoryPicker not showing in SwiftUI
 
 
Q