Remove TabBar item in Swift

For those who just want to disable one item. Use this code from @Daniele's solution. and place it in your UITabBarController class

viewDidLoad() {

let index = 0 //0 to 5
viewControllers?.remove(at: index)

}

You want to set the viewControllers property of your tabBarController with an array where you excluded the particular viewController that you don't want to have anymore.

if let tabBarController = self.tabBarController {
    let indexToRemove = 3
    if indexToRemove < tabBarController.viewControllers?.count {
        var viewControllers = tabBarController.viewControllers
        viewControllers?.remove(at: indexToRemove)
        tabBarController.viewControllers = viewControllers
    }
}