'Xcode AX problem Bug with Siri Extension only occurs on physical device

I have an application that's using a Siri extension, and I am having issues when the user attempts to add their own custom voice shortcut. This issue can only be reproduced on a physical device and doesn't appear when I run the app on the Simulator.

Immediately after the user taps the "Add to Siri", the code in the below IBAction handler executes:

//ViewController.swift

@IBAction func didTapAddToSiriBtn(_ sender: Any) {
                guard let shortcut = INShortcut(intent: ShowCommandIntent()) else{return}
                let addShortCutVC = INUIAddVoiceShortcutViewController(shortcut: shortcut)
                addShortCutVC.delegate = self
                DispatchQueue.main.async {
                    self.present(addShortCutVC,animated: true,completion: nil)
                }

After the self.present() runs, it causes the following message to be output to the console:
[AXRuntimeCommon] Unknown client: {MY_APP_NAME}

Then, the user adds their custom shortcut to Siri, and the following stack trace prints in the console (3 times, shown only once for brevity):

2022-02-21 03:03:50.706169-0800 MYAPP[684:21893] [AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:711 (
    0   AXRuntime                           0x00000001b2fbb2d8 0920B415-57F5-3DBC-A02F-8D83F36AF2F0 + 365272
    1   AXRuntime                           0x00000001b2f66088 _AXGetPortFromCache + 560
    2   AXRuntime                           0x00000001b2f67718 AXUIElementPerformFencedActionWithValue + 464
    3   UIKit                               0x00000001df6622fc F7891AA4-68E5-311F-BFDF-EA21213976CD + 901884
    4   libdispatch.dylib                   0x00000001011180b4 _dispatch_call_block_and_release + 32
    5   libdispatch.dylib                   0x0000000101119de0 _dispatch_client_callout + 20
    6   libdispatch.dylib                   0x0000000101121ef0 _dispatch_lane_serial_drain + 788
    7   libdispatch.dylib                   0x0000000101122d14 _dispatch_lane_invoke + 444
    8   libdispatch.dylib                   0x000000010112fa50 _dispatch_workloop_worker_thread + 1600
    9   libsystem_pthread.dylib             0x00000001df36e7a4 _pthread_wqthread + 276
    10  libsystem_pthread.dylib             0x00000001df37574c start_wqthread + 8
)

I've tried restarting both computer and the test device and cleaning the build folder but with no success. What could be the issue here? I know a lot of other Extensions have had this issue.

Any help is appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source