How to remove programmatically a tab bar item created in parent class NIB file?

This is what it works for me for Swift 4 and 5

  1. Create a custom UITabBarController class.
  2. Assign the custom UITabBarController class to the view on storyboard.
  3. Remove the UIViewController on viewDidLoad:

    class TabViewController: UITabBarController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            self.viewControllers?.remove(at: 1)
        }
    }
    

The following code has the solution:

NSMutableArray *tbViewControllers = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]];
[tbViewControllers removeObjectAtIndex:2];
[self.tabBarController setViewControllers:tbViewControllers];

Swift 4

func removeTab(at index: Int) {
    guard let viewControllers = self.tabBarController?.viewControllers as? NSMutableArray else { return }
    viewControllers.removeObject(at: index)
    self.tabBarController?.viewControllers = (viewControllers as! [UIViewController])
}