How do I manually focus a certain cell in a UICollectionView only on first load?

I'm pretty new to swift and I'm trying to make a certain cell focused in a horizontal scrollable UICollectionView when I load into a page for the first time. The page fits about 4 cells across horizontally. Right now I'm trying to do:

collectionView.scrollToItem(IndexPath(row: 3, section: 0), at: .left, animated: true)

in viewDidLoad in order to focus the fourth cell upon clicking into the page. If there are at least 7 items in the collection view, this will work correctly since the fourth cell will be on the left, but if not, it will end up focusing on one of the first 3 items, since you can't scroll past the fourth item enough so that the fourth item is on the left. How do I make sure the fourth item is not only scrolled to but also explicitly focused?

I tried using func indexPathForPreferredFocusedView(in collectionView: UICollectionView) -> IndexPath? as well, which seems to make it work, but the problem is I don't want the fourth item to be focused all the time, only on the first load of this specific page. I also use this collection view in other places in the app where I don't want this manual focus.

I tried to override preferredFocusEnvironments with the cell at that index path but for some reason, collectionView.cellForItem(at: IndexPath(row: 3, section: 0)) always returns nil.

It seems like focusing the index path is the only thing that seems to work but I can't figure out how to manually focus an index path without overriding indexPathForPreferredFocusedView. Any advice? Thanks!