Ramotion / animated-tab-bar

:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
https://www.ramotion.com/animated-tab-bar-ios-app-development-ui-library/
MIT License
11.12k stars 1.33k forks source link

Crash in RAMAnimatedTabBarController init process (5.1.0) #268

Closed Nightstep closed 4 years ago

Nightstep commented 4 years ago

Xcode version: 11.1 Library version: 5.1.0 Crash on RAMAnimatedTabBarController.init()

Good day, Getting crash in RAMAnimatedTabBarController init call. The thing is tab bar immediately calls viewDidLoad() method, which calls initializeContainers(). The line 135 expects that tabbar.items is in range 0..5, but it's always nil. Thats why it always throws fatalError("More button not supported") There's no other initializers with containers injection as well. (init(tabs: [UIViewController]))

Code snipper which causes fatal error:

    // MARK: create methods
    private func initializeContainers() {
        guard let items = tabBar.items, items.count <= 5 else {
            fatalError("More button not supported")
        }
igork-ramotion commented 4 years ago

@Nightstep It happen because you need to assign viewControllers before add TabBarController into view hierarchy. I've improve error handling for that case, so now it will not crash. But still for correct work you need to assign your tab view controllers

Nightstep commented 4 years ago

It crashes right on init() call. There's no way to add viewControllers because the compiler just doesn't go to the next line of execution.