     }
 
     open func tabBarController(_ tabBarController: UITabBarController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
-        if panGestureRecognizer.state == .began || panGestureRecognizer.state == .changed {
-            return SwipeInteractor(gestureRecognizer: panGestureRecognizer, edge: currentAnimatedTransitioningType?.targetEdge ?? .right)
+        guard let panGesture = panGestureRecognizer else { return nil }
+        if panGesture.state == .began || panGesture.state == .changed {
+            return SwipeInteractor(gestureRecognizer: panGesture, edge: currentAnimatedTransitioningType?.targetEdge ?? .right)
         } else {
             return nil
         }

            guard panGestureRecognizer != nil else {
                return
            }
            panGestureRecognizer.minimumNumberOfTouches = minimumNumberOfTouches
        }
    }
    


    /// Enables/Disables swipes on the tabbar controller.
    open var isSwipeEnabled = true {
        didSet { panGestureRecognizer?.isEnabled = isSwipeEnabled }
    }

    /// Allowed swipe directions. Only applied if `isSwipeEnabled` equals `true`.
    open var allowedSwipeDirection: AllowedSwipeDirection = .both

    /// Enables/Disables cycling swipes on the tabBar controller. default value is 'false'
    open var isCyclingEnabled = false
