Skip to content

fix(ios): skip an empty image name instead of looking it up - #1230

Open
rsoaresdev wants to merge 1 commit into
react-native-menu:masterfrom
rsoaresdev:fix/ios-skip-empty-image
Open

rsoaresdev wants to merge 1 commit into
react-native-menu:masterfrom
rsoaresdev:fix/ios-skip-empty-image

Conversation

@rsoaresdev

Copy link
Copy Markdown

Overview

On the new architecture an action without an image still reaches native code with one. The codegen spec declares image?: string, the generated C++ struct holds a std::string that defaults to empty, and ios/NewArch/MenuView.mm always puts it in the action dictionary:

@"image": [NSString stringWithUTF8String:action.image.c_str()],

So RCTMenuAction receives "", UIImage(systemName: "") returns nil, and the fallback UIImage(named: "") makes UIKit log this once for every action without an icon, each time the menu is built:

[com.apple.coreui] CUICatalog: Invalid asset name supplied: ''

A screen with a few menus prints it dozens of times. Nothing breaks (the image ends up nil, which is what an icon-less action wants), but it buries real messages in the Xcode console.

This skips the lookup when the name is empty, in RCTMenuItem.swift and in RCTAlertAction.swift (the iOS 13 action sheet path reads the same dictionary). The old architecture never sends an empty string, so its behaviour is unchanged, and a non-empty name is looked up exactly as before.

Test Plan

  • New architecture, iOS: a MenuView with an action that has no image and one that has image: "trash". Before, opening the menu logs CUICatalog: Invalid asset name supplied: ''; after, it does not, and the trash symbol still shows.
  • An action with an asset catalog image name still falls back to UIImage(named:) as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant