     
     // MARK: - Setup
     
+    // TODO: Improve sessions injection
+    // at the moment the session is not used, see TabBarCoordinator `init`.
     init(router: RootRouterType, session: MXSession?) {
         self.rootRouter = router
         self.session = session
         
-        // TODO: Use a dedicated stoyboard and SwiftGen to access it
-        let storyboard = UIStoryboard(name: "Main", bundle: nil)
-        guard let splitViewController = storyboard.instantiateViewController(withIdentifier: "RiotSplitViewController") as? UISplitViewController else {
-            fatalError("[SplitViewCoordinator] Can't load RiotSplitViewController")
-        }
+        let splitViewController = UISplitViewController()
         splitViewController.preferredDisplayMode = .allVisible
         self.splitViewController = splitViewController
-        
-        guard let masterNavigationController = splitViewController.viewControllers.first as? UINavigationController else {
-            fatalError("[SplitViewCoordinator] Can't load masterNavigationController")
-        }
-        self.masterNavigationController = masterNavigationController
-        
-        guard let masterTabBarController = masterNavigationController.viewControllers.first as? MasterTabBarController else {
-            fatalError("[SplitViewCoordinator] Can't load masterTabBarController")
-        }
-        self.masterTabBarController = masterTabBarController
     }
     
     // MARK: - Public methods
     
     func start() {
         self.splitViewController.delegate = self
+        
+        let tabBarCoordinator = self.createTabBarCoordinator()
+        tabBarCoordinator.delegate = self
+        tabBarCoordinator.splitViewMasterPresentableDelegate = self
+        tabBarCoordinator.start()
+        let detailNavigationController = self.createDetailNavigationController()
+        
+        self.splitViewController.viewControllers = [tabBarCoordinator.toPresentable(), detailNavigationController]
+                
+        self.add(childCoordinator: tabBarCoordinator)
+        
+        self.tabBarCoordinator = tabBarCoordinator
+        self.masterPresentable = tabBarCoordinator
+        self.detailNavigationController = detailNavigationController
+        
         self.rootRouter.setRootModule(self.splitViewController)
     }
     

    }
    
    func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
        if (masterTabBarController.currentRoomViewController == nil) && (masterTabBarController.currentContactDetailViewController == nil) && (masterTabBarController.currentGroupDetailViewController == nil) {
            // Return YES to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
            return true
        } else {
            return false
        }
    }
}

// MARK: - UINavigationControllerDelegate
extension SplitViewCoordinator: UINavigationControllerDelegate {
    
    func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
        
        if viewController == masterTabBarController {
            masterNavigationController.delegate = nil
            
            // For unknown reason, the navigation bar is not restored correctly by [popToViewController:animated:]
            // when a ViewController has hidden it (see MXKAttachmentsViewController).
            // Patch: restore navigation bar by default here.
            masterNavigationController.isNavigationBarHidden = false

            // Release the current selected item (room/contact/...).
            masterTabBarController.releaseSelectedItem()

            if let popToHomeViewControllerCompletion = self.popToHomeViewControllerCompletion {
                let popToHomeViewControllerCompletion2: (() -> Void)? = popToHomeViewControllerCompletion
                self.popToHomeViewControllerCompletion = nil

                DispatchQueue.main.async {
                    popToHomeViewControllerCompletion2?()
                }
            }
        }
        
    }
}

    
    private let splitViewController: UISplitViewController
    
    private weak var masterPresentable: SplitViewMasterPresentable?
    private weak var detailNavigationController: UINavigationController?
    
    private weak var tabBarCoordinator: TabBarCoordinatorType?
    
    // MARK: Public
    
