apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.
MIT License
1.36k stars 160 forks source link

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'At least 1 subitem is required for a group' #73

Closed ryangittings closed 4 years ago

ryangittings commented 4 years ago

Getting the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'At least 1 subitem is required for a group'

This is on ASCollectionViewLayout.swift, line 112. Once again, if I can help at all let me know! :)

apptekstudios commented 4 years ago

Ah this would be related to the fix for #68. To fix the request for a phantom section I returned an empty NSCollectionLayoutSection. It seems this placeholder also needs a sub item configured. I’ll try look at this tomorrow, but I would expect the error to go away if you add a subitem to that placeholder on line 112

ryangittings commented 4 years ago

Legend, I'll await a fix tomorrow! Really appreciate it.

apptekstudios commented 4 years ago

Should be fixed on the dev branch now. I still can't actually reproduce a case where that guard statement is actually triggered though.

ryangittings commented 4 years ago

It seems to occur for me when you’re on a view and you push to the same view with different data from that view.

apptekstudios commented 4 years ago

This might be due to some unexpected SwiftUI behaviour where it's reusing the UIViewController underlying ASCollectionView instead of making a new one. Try wrapping the different uses of that view with an .id("SOMEUNIQUESTRING") with a different string and see if that makes a difference. A similar issue is happening with TabView (#44).

If this is the case: the fix that's currently in place will avoid the crash but might have unexpected visual side-effects (are any sections appearing as a list and shouldn't be?)