Menu works fine in iPad and Mac Catalyst but crashed on Apple Silicon

Hi,

I have an iPad app that has menus, like:

 CommandGroup(replacing: .help) {                 Button("Help") { showHelp = true }                     .keyboardShortcut("/")  }

They works fine in iPad and also if compiled to Mac Catalyst, but will crash on Apple Silicon Mac when selected the menu items with errors like:

[General] -[_UIEditMenuInteractionMenuController propertyList]: unrecognized selector sent to instance 0x600000190540

I did not use storyboard and only use SwiftUI. Any suggestions?

Note: of course the best solution is to compile to Mac Catalyst, but the app has some other issues when run in Mac Catalyst. So I can only release it as iPad app.

  • Hi limtc! Did you solved this problem somehow? I still get a crash on Mac Silicon and Xcode Version 14.3 beta (14E5197f). Any hint would be very welcome. Thanks!

Add a Comment

Replies

Hi!

I have exactly the same problem and tried a lot of combinations to get something basic working; without luck. Always the "unrecognized selector" for all commands I define myself, independent of the integration command (after/replace/add new menus). Standard menu items are not crashing. And it doesn't make a difference between keyboard shortcuts or selecting the menu with the mouse.

Would be great if you post something when you get it solved; I will do the same!

Best Pimau

On Xcode Version 14.2 (14C18) the crash looks like this:

2023-01-28 15:15:00.606780+0100 tk22[3627:189444] -[_UIEditMenuInteractionMenuController propertyList]: unrecognized selector sent to instance 0x600000ab12c0

2023-01-28 15:15:00.607260+0100 tk22[3627:189444] [General] An uncaught exception was raised

2023-01-28 15:15:00.607401+0100 tk22[3627:189444] [General] -[_UIEditMenuInteractionMenuController propertyList]: unrecognized selector sent to instance 0x600000ab12c0

2023-01-28 15:15:00.613360+0100 tk22[3627:189444] [General] (

0   CoreFoundation                      0x00000001a5dd33f8 __exceptionPreprocess + 176

1   libobjc.A.dylib                     0x00000001a591eea8 objc_exception_throw + 60

2   CoreFoundation                      0x00000001a5e75c1c -[NSObject(NSObject) __retain_OA] + 0

3   CoreFoundation                      0x00000001a5d39670 ___forwarding___ + 1600

4   CoreFoundation                      0x00000001a5d38f70 _CF_forwarding_prep_0 + 96

5   SwiftUI                             0x00000001e6b061dc OUTLINED_FUNCTION_4 + 2120

6   SwiftUI                             0x00000001e640a26c OUTLINED_FUNCTION_10 + 8884

7   SwiftUI                             0x00000001e6db4518 OUTLINED_FUNCTION_205 + 18552

8   SwiftUI                             0x00000001e6db4574 OUTLINED_FUNCTION_205 + 18644

9   UIKitCore                           0x00000001d0cc4d3c -[_UIMenuBarItem _performAction] + 300

10  UIKitMacHelper                      0x00000001bc32d81c -[UINSResponderProxy _performMenuProxyActionForSender:] + 252

11  CoreFoundation                      0x00000001a5d3adc4 __invoking___ + 148

12  CoreFoundation                      0x00000001a5d3ac3c -[NSInvocation invoke] + 428

13  UIKitMacHelper                      0x00000001bc32d6f0 -[UINSResponderProxy forwardInvocation:] + 188

14  CoreFoundation                      0x00000001a5d39400 ___forwarding___ + 976

15  CoreFoundation                      0x00000001a5d38f70 _CF_forwarding_prep_0 + 96

16  AppKit                              0x00000001a9180fa0 -[NSApplication(NSResponder) sendAction:to:from:] + 440

17  AppKit                              0x00000001a924d618 -[NSMenuItem _corePerformAction] + 336

18  AppKit                              0x00000001a924d394 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 104

19  AppKit                              0x00000001a9289030 -[NSMenu performActionForItemAtIndex:] + 200

20  AppKit                              0x00000001a9288f50 -[NSMenu _internalPerformActionForItemAtIndex:] + 76

21  AppKit                              0x00000001a9288da4 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 108

22  AppKit                              0x00000001a923595c NSSLMMenuEventHandler + 640

23  HIToolbox                           0x00000001af4044c0 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1092

24  HIToolbox                           0x00000001af403940 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 356

25  HIToolbox                           0x00000001af419bb8 SendEventToEventTarget + 40

26  HIToolbox                           0x00000001af479338 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 416

27  HIToolbox                           0x00000001af49db60 SendMenuCommandWithContextAndModifiers + 56

28  HIToolbox                           0x00000001af49daf0 SendMenuItemSelectedEvent + 352

29  HIToolbox                           0x00000001af49d91c _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 100

30  HIToolbox                           0x00000001af49e2dc _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 560

31  HIToolbox                           0x00000001af49dffc _HandleMenuSelection2 + 416

32  AppKit                              0x00000001a912b2bc _NSHandleCarbonMenuEvent + 256

33  AppKit                              0x00000001a912b0e0 _DPSEventHandledByCarbon + 60

34  AppKit                              0x00000001a8fd7bac -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2256

35  AppKit                              0x00000001a8fcb9e4 -[NSApplication run] + 464

36  AppKit                              0x00000001a8fa2e28 NSApplicationMain + 880

37  AppKit                              0x00000001a91fca44 +[NSWindow _savedFrameFromString:] + 0

38  UIKitMacHelper                      0x00000001bc28aba8 UINSApplicationMain + 988

39  UIKitCore                           0x00000001cfd20934 UIApplicationMain + 148

40  SwiftUI                             0x00000001e6a78b4c OUTLINED_FUNCTION_51 + 608

41  SwiftUI                             0x00000001e6a78998 OUTLINED_FUNCTION_51 + 172

42  SwiftUI                             0x00000001e6050c08 OUTLINED_FUNCTION_10 + 140

43  tk22                                0x00000001051286bc $s4tk220A3AppV5$mainyyFZ + 40

44  tk22                                0x000000010512a450 main + 12

45  dyld                                0x00000001a594fe50 start + 2544

I have the same problem and after wasting a lot of time, it turns out the keyboardShortcut modifier appears to be bjorked when running using the "My Mac (Designed for iPad)" option.

To get around it, I created the following View extension:

extension View {
    @ViewBuilder func keyboardShortcutHack(_ key: KeyEquivalent, modifiers: EventModifiers) -> some View {
        /* #if targetEnvironment(macCatalyst) and os(macOS) don't work when running using the "My Mac (Designed for iPad)" */
        if ProcessInfo.processInfo.isiOSAppOnMac {
            self
        }
        else {
            self.keyboardShortcut(key, modifiers: modifiers)
        }
    }
}

I did file this via the Feedback Assistant with Apple.

  • Yes, this is working for me. Because of the lack of usable debug info in Xcode this was really hard to find out, even when the solution looks quite simple. Thank you for sharing it with us!

Add a Comment

I am seeing this problem in Xcode 15.1 beta.

I filed a report in Feedback Assistant as well FB13258087

Hope to see a fix/workaround