Our app had the same crash. We were trying to access a mockCell used for calculating the height of the cell before the collection view was accessible. After some research, we realized we don't need the heightForContent() anymore. Here is the code change:
❌ Before:
func size(for indexPath: IndexPath) -> CGSize {
let mockCell = settingItemCell(collectionView, indexPath: indexPath) as? SettingButtonCell {
height = mockCell.heightForContent(withWidth: contentWidth)
}
✅ After:
func size(for indexPath: IndexPath) -> CGSize {
height = 40
}
The following line was causing the crash:
let mockCell = settingItemCell(collectionView, indexPath: indexPath) as? SettingButtonCell