The accessibility identifier is a developer generated ID for GUI objects, which can be used for automation tests.
A UIBarButtonItem does not implement
UIBarButtonItem
The subclassing UIBarButtonItem is a good solution. Depending on your needs, though, it may make more sense to simply assign the accessibilityIdentifier to the custom image of your UIBarButtonItem, assuming your UIBarButtonItem uses a custom image.
accessibilityIdentifier