No visible @interface for UITabBar setScrollEdgeAppearance

Viewed 1482

today i met with issue on Xcode 12. When i tried iOS 15 version of app i noticed that tabbar background changed. I solved this by adding this line of code

if (@available(iOS 15.0, *)) {
    [[UITabBar appearance] setScrollEdgeAppearance:tabBarAppearance.appearance];
}

But after I swapped back to Xcode 12 from Xcode 13 i got this issue.

No visible @interface for 'UITabBar' declares the selector 'setScrollEdgeAppearance:'

Seems like Xcode12 bug for me but maybe i am wrong.

Edit: added if statement which was in code

3 Answers

The only solution that worked for us in a swift-file:

#if swift(>=5.5) // Only run on Xcode version >= 13 (Swift 5.5 was shipped first with Xcode 13).
        if #available(iOS 15.0, *) {
            UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
        }
#endif

That snippet makes sure it is only compiled with Xcode Version > 13 and only runs for iOS 15. Swift 5.5 was introduced with Xcode 13.

I think that's because scrollEdgeAppearance was just a property of UINavigationBar for iOS < 15 versions. Since iOS 15 They've extended it to all others navigation bars

As per Apple doc:

When running on apps that use iOS 14 or earlier, this property applies to navigation bars with large titles. In iOS 15, this property applies to all navigation bars.

It's only available in Xcode 13. So we did this to fix the issue and be able to compile on both Xcode 12 and 13:

#if __clang_major__ >= 13
if (@available(iOS 15.0, *)) {
    [[UITabBar appearance] setScrollEdgeAppearance:tabBarAppearance.appearance];
}
#endif
Related