I'm adding search controller like this:
        viewController.navigationItem.searchController = searchController
        viewController.navigationItem.hidesSearchBarWhenScrolling = false
        viewController.definesPresentationContext = true
        searchController.dimsBackgroundDuringPresentation = false
        searchBarContainer.translatesAutoresizingMaskIntoConstraints = false
        searchBarContainer.heightAnchor.constraint(equalToConstant: 0).isActive = true
and when try to swipe right to pop current viewController (interactive pop gesture activates here) but stay on the same controller the search bar just disappears.
viewController.navigationItem.searchController
holds added search controller but it's not visible.
                        
Try to add this code to whatever class
viewControlleris an instance of:That did the trick for me.