Can't see into UICollectionView header

Hi. I’m writing tests for an iOS app and I’m having the following issue:

I have a UICollectionView with a header. The header is a subclass of UICollectionReusableView with some standard UIKit widgets inside (UIButton, UILabel). I have given the view, the header, and the widgets accessibilityIdentifiers in Xcode’s storyboard view.

The problem is that the header does not appear in the Appium Inspector hierarchy at all. The UICollectionView appears, as do its cells.

(The header also doesn’t show in Instruments/Automator, so technically it’s not really an Appium problem.)

Does anyone have any idea why my header is opaque to the accessibility API?

Never mind, I figured it out.

When a UICollectionView has 1 or more cells, then the cells and the header and footer elements will be exposed in the UI hierarchy as expected.

When a UICollectionView has 0 cells, even if the header and footer are displayed they will not be exposed in the UI hierarchy. This feels like an Apple bug.

So for my purposes the answer is to ensure that the view has at least 1 cell before attempting to test it.