I am trying to create a Facebook messenger like application from a youtube tutorial. I have a home page where the user click BarButton to open the chats. The Home page works
Probably when you present your ChatViewController you have something like:
let chatVC = ChatViewController()
But according to Apple doc:
class UICollectionViewController
When you initialize the controller, using the init(collectionViewLayout:) method, you specify the layout the collection view should have.
So you need:
let chatVC = ChatViewController(collectionViewLayout: UICollectionViewFlowLayout())
Seems like you skipped steps in a tutorial which is using Interface Builder.
The problem is, that in your ChatViewController there is a missing connection between your "collectionView?" and the corresponding UICollectionView (so called referencing outlet) in the Interface Builder.
This is a very basic task in iOS development. Please have a look at the official Apple documentation under the topic "Create Outlets for UI Elements": Connect UI to Code